LCOV - code coverage report
Current view: top level - vnsw/agent/oper - docker_instance_adapter.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 59 0.0 %
Date: 2026-08-03 02:19:58 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "oper/docker_instance_adapter.h"
       2             : #include "oper/service_instance.h"
       3             : #include "oper/instance_task.h"
       4             : 
       5           0 : InstanceTask* DockerInstanceAdapter::CreateStartTask(const ServiceInstance::Properties &props, bool update) {
       6           0 :     if (docker_cmd_.length() == 0) {
       7           0 :         return NULL;
       8             :     }
       9           0 :     std::stringstream cmd_str;
      10           0 :     cmd_str << "sudo " << docker_cmd_ << " create";
      11           0 :     cmd_str << " " << UuidToString(props.instance_id);
      12           0 :     cmd_str << " --image " << props.image_name;
      13             : 
      14           0 :     if (props.vmi_inside != boost::uuids::nil_uuid()) {
      15           0 :         cmd_str << " --vmi-left-id " << UuidToString(props.vmi_inside);
      16           0 :         if (props.ip_prefix_len_inside != -1 && !props.ip_addr_inside.empty()) {
      17           0 :             cmd_str << " --vmi-left-ip " << props.ip_addr_inside << "/";
      18           0 :             cmd_str << props.ip_prefix_len_inside;
      19             :         } else {
      20           0 :             cmd_str << " --vmi-left-ip 0.0.0.0/0";
      21             :         }
      22           0 :         if (!props.mac_addr_inside.empty()) {
      23           0 :             cmd_str << " --vmi-left-mac " << props.mac_addr_inside;
      24             :         } else {
      25           0 :             cmd_str << " --vmi-left-mac 00:00:00:00:00:00";
      26             :         }
      27             :     }
      28           0 :     if (props.vmi_outside != boost::uuids::nil_uuid()) {
      29           0 :         cmd_str << " --vmi-right-id " << UuidToString(props.vmi_outside);
      30           0 :         if (props.ip_prefix_len_outside != -1 && !props.ip_addr_outside.empty())  {
      31           0 :             cmd_str << " --vmi-right-ip " << props.ip_addr_outside << "/";
      32           0 :             cmd_str << props.ip_prefix_len_outside;
      33             :         } else {
      34           0 :             cmd_str << " --vmi-right-ip 0.0.0.0/0";
      35             :         }
      36           0 :         if (!props.mac_addr_outside.empty()) {
      37           0 :             cmd_str << " --vmi-right-mac " << props.mac_addr_outside;
      38             :         } else {
      39           0 :             cmd_str << " --vmi-right-mac 00:00:00:00:00:00";
      40             :         }
      41             :     }
      42           0 :     if (props.vmi_management != boost::uuids::nil_uuid()) {
      43           0 :         cmd_str << " --vmi-management-id " << UuidToString(props.vmi_management);
      44           0 :         if (props.ip_prefix_len_management != -1 && !props.ip_addr_management.empty())  {
      45           0 :             cmd_str << " --vmi-management-ip " << props.ip_addr_management << "/";
      46           0 :             cmd_str << props.ip_prefix_len_management;
      47             :         } else {
      48           0 :             cmd_str << " --vmi-management-ip 0.0.0.0/0";
      49             :         }
      50           0 :         if (!props.mac_addr_management.empty()) {
      51           0 :             cmd_str << " --vmi-management-mac " << props.mac_addr_management;
      52             :         } else {
      53           0 :             cmd_str << " --vmi-management-mac 00:00:00:00:00:00";
      54             :         }
      55             :     }
      56             : 
      57           0 :     if (!props.instance_data.empty()) {
      58           0 :         cmd_str << " --instance-data " << props.instance_data;
      59             :     }
      60             : 
      61           0 :     if (update) {
      62           0 :         cmd_str << " --update";
      63             :     }
      64             : 
      65             : 
      66           0 :     return new InstanceTaskExecvp("NetNS", cmd_str.str(), START,
      67           0 :                                   agent_->event_manager());
      68           0 : }
      69             : 
      70           0 : InstanceTask* DockerInstanceAdapter::CreateStopTask(const ServiceInstance::Properties &props) {
      71           0 :     if (docker_cmd_.length() == 0) {
      72           0 :         return NULL;
      73             :     }
      74             : 
      75           0 :     std::stringstream cmd_str;
      76           0 :     cmd_str << "sudo " << docker_cmd_ << " destroy";
      77           0 :     cmd_str << " " << UuidToString(props.instance_id);
      78             : 
      79           0 :     if (props.vmi_inside != boost::uuids::nil_uuid()) {
      80           0 :         cmd_str << " --vmi-left-id " << UuidToString(props.vmi_inside);
      81             :     }
      82           0 :     if (props.vmi_outside != boost::uuids::nil_uuid()) {
      83           0 :         cmd_str << " --vmi-right-id " << UuidToString(props.vmi_outside);
      84             :     }
      85           0 :     if (props.vmi_management != boost::uuids::nil_uuid()) {
      86           0 :         cmd_str << " --vmi-management-id " << UuidToString(props.vmi_management);
      87             :     }
      88           0 :     return new InstanceTaskExecvp("NetNS", cmd_str.str(), STOP,
      89           0 :                                   agent_->event_manager());
      90           0 : }
      91             : 
      92           0 : bool DockerInstanceAdapter::isApplicable(const ServiceInstance::Properties &props) {
      93           0 :     return (props.virtualization_type == ServiceInstance::VRouterInstance
      94           0 :             && props.vrouter_instance_type == ServiceInstance::Docker);
      95             : }

Generated by: LCOV version 1.14