Exemplo n.º 1
0
    def args2body(self, parsed_args):
        _network_id = quantumv20.find_resourceid_by_name_or_id(
            self.get_client(), 'network', parsed_args.network_id)
        body = {'subnet': {'cidr': parsed_args.cidr,
                           'network_id': _network_id,
                           'ip_version': parsed_args.ip_version, }, }

        if parsed_args.gateway and parsed_args.no_gateway:
            raise exceptions.CommandError("--gateway option and "
                                          "--no-gateway option can "
                                          "not be used same time")
        if parsed_args.no_gateway:
            body['subnet'].update({'gateway_ip': None})
        if parsed_args.gateway:
            body['subnet'].update({'gateway_ip': parsed_args.gateway})
        if parsed_args.tenant_id:
            body['subnet'].update({'tenant_id': parsed_args.tenant_id})
        if parsed_args.name:
            body['subnet'].update({'name': parsed_args.name})
        ips = []
        if parsed_args.allocation_pool:
            for ip_spec in parsed_args.allocation_pool:
                ips.append(utils.str2dict(ip_spec))
        if ips:
            body['subnet'].update({'allocation_pools': ips})

        return body
Exemplo n.º 2
0
 def args2body(self, parsed_args):
     _network_id = quantumv20.find_resourceid_by_name_or_id(
         self.get_client(), 'network', parsed_args.network_id)
     body = {'port': {'admin_state_up': parsed_args.admin_state_down,
                      'network_id': _network_id, }, }
     if parsed_args.mac_address:
         body['port'].update({'mac_address': parsed_args.mac_address})
     if parsed_args.device_id:
         body['port'].update({'device_id': parsed_args.device_id})
     if parsed_args.tenant_id:
         body['port'].update({'tenant_id': parsed_args.tenant_id})
     if parsed_args.name:
         body['port'].update({'name': parsed_args.name})
     ips = []
     if parsed_args.fixed_ip:
         for ip_spec in parsed_args.fixed_ip:
             ip_dict = utils.str2dict(ip_spec)
             if 'subnet_id' in ip_dict:
                 subnet_name_id = ip_dict['subnet_id']
                 _subnet_id = quantumv20.find_resourceid_by_name_or_id(
                     self.get_client(), 'subnet', subnet_name_id)
                 ip_dict['subnet_id'] = _subnet_id
             ips.append(ip_dict)
     if ips:
         body['port'].update({'fixed_ips': ips})
     return body
Exemplo n.º 3
0
 def args2body(self, parsed_args):
     _network_id = quantumv20.find_resourceid_by_name_or_id(
         self.get_client(), 'network', parsed_args.network_id)
     body = {
         'port': {
             'admin_state_up': parsed_args.admin_state_down,
             'network_id': _network_id,
         },
     }
     if parsed_args.mac_address:
         body['port'].update({'mac_address': parsed_args.mac_address})
     if parsed_args.device_id:
         body['port'].update({'device_id': parsed_args.device_id})
     if parsed_args.tenant_id:
         body['port'].update({'tenant_id': parsed_args.tenant_id})
     if parsed_args.name:
         body['port'].update({'name': parsed_args.name})
     ips = []
     if parsed_args.fixed_ip:
         for ip_spec in parsed_args.fixed_ip:
             ip_dict = utils.str2dict(ip_spec)
             if 'subnet_id' in ip_dict:
                 subnet_name_id = ip_dict['subnet_id']
                 _subnet_id = quantumv20.find_resourceid_by_name_or_id(
                     self.get_client(), 'subnet', subnet_name_id)
                 ip_dict['subnet_id'] = _subnet_id
             ips.append(ip_dict)
     if ips:
         body['port'].update({'fixed_ips': ips})
     return body
 def args2body(self, parsed_args):
     body = {self.resource: {
         'name': parsed_args.name}}
     devices = []
     if parsed_args.device:
         for device in parsed_args.device:
             devices.append(utils.str2dict(device))
     if devices:
         body[self.resource].update({'devices': devices})
     if parsed_args.tenant_id:
         body[self.resource].update({'tenant_id': parsed_args.tenant_id})
     return body
Exemplo n.º 5
0
 def args2body(self, parsed_args):
     body = {"port": {"admin_state_up": parsed_args.admin_state_down, "network_id": parsed_args.network_id}}
     if parsed_args.mac_address:
         body["port"].update({"mac_address": parsed_args.mac_address})
     if parsed_args.device_id:
         body["port"].update({"device_id": parsed_args.device_id})
     if parsed_args.tenant_id:
         body["port"].update({"tenant_id": parsed_args.tenant_id})
     ips = []
     if parsed_args.fixed_ip:
         for ip_spec in parsed_args.fixed_ip:
             ips.append(utils.str2dict(ip_spec))
     if ips:
         body["port"].update({"fixed_ips": ips})
     return body
Exemplo n.º 6
0
 def args2body(self, parsed_args):
     body = {'port': {'admin_state_up': parsed_args.admin_state_down,
                      'network_id': parsed_args.network_id, }, }
     if parsed_args.mac_address:
         body['port'].update({'mac_address': parsed_args.mac_address})
     if parsed_args.device_id:
         body['port'].update({'device_id': parsed_args.device_id})
     if parsed_args.tenant_id:
         body['port'].update({'tenant_id': parsed_args.tenant_id})
     ips = []
     if parsed_args.fixed_ip:
         for ip_spec in parsed_args.fixed_ip:
             ips.append(utils.str2dict(ip_spec))
     if ips:
         body['port'].update({'fixed_ips': ips})
     return body
Exemplo n.º 7
0
    def args2body(self, parsed_args):
        body = {'subnet': {'cidr': parsed_args.cidr,
                           'network_id': parsed_args.network_id,
                           'ip_version': parsed_args.ip_version, }, }
        if parsed_args.gateway:
            body['subnet'].update({'gateway_ip': parsed_args.gateway})
        if parsed_args.tenant_id:
            body['subnet'].update({'tenant_id': parsed_args.tenant_id})
        ips = []
        if parsed_args.allocation_pool:
            for ip_spec in parsed_args.allocation_pool:
                ips.append(utils.str2dict(ip_spec))
        if ips:
            body['subnet'].update({'allocation_pools': ips})

        return body
Exemplo n.º 8
0
    def args2body(self, parsed_args):
        _network_id = quantumv20.find_resourceid_by_name_or_id(self.get_client(), "network", parsed_args.network_id)
        body = {"subnet": {"cidr": parsed_args.cidr, "network_id": _network_id, "ip_version": parsed_args.ip_version}}
        if parsed_args.gateway:
            body["subnet"].update({"gateway_ip": parsed_args.gateway})
        if parsed_args.tenant_id:
            body["subnet"].update({"tenant_id": parsed_args.tenant_id})
        if parsed_args.name:
            body["subnet"].update({"name": parsed_args.name})
        ips = []
        if parsed_args.allocation_pool:
            for ip_spec in parsed_args.allocation_pool:
                ips.append(utils.str2dict(ip_spec))
        if ips:
            body["subnet"].update({"allocation_pools": ips})

        return body
Exemplo n.º 9
0
    def args2body(self, parsed_args):
        body = {
            "subnet": {
                "cidr": parsed_args.cidr,
                "network_id": parsed_args.network_id,
                "ip_version": parsed_args.ip_version,
            }
        }
        if parsed_args.gateway:
            body["subnet"].update({"gateway_ip": parsed_args.gateway})
        if parsed_args.tenant_id:
            body["subnet"].update({"tenant_id": parsed_args.tenant_id})
        ips = []
        if parsed_args.allocation_pool:
            for ip_spec in parsed_args.allocation_pool:
                ips.append(utils.str2dict(ip_spec))
        if ips:
            body["subnet"].update({"allocation_pools": ips})

        return body
Exemplo n.º 10
0
 def test_string_to_dictionary(self):
     input_str = 'key1=value1,key2=value2'
     expected = {'key1': 'value1', 'key2': 'value2'}
     self.assertEqual(expected, utils.str2dict(input_str))