Esempio n. 1
0
 def _dict_to_obj(cls, json_dict):
     rules = []
     for rule in json_dict.get('rules'):
         rules.append(SecurityGroupRule._dict_to_obj(rule))
     return SecurityGroup(id=json_dict.get('id'),
                          name=json_dict.get('name'),
                          description=json_dict.get('description'),
                          rules=rules,
                          tenant_id=json_dict.get('tenant_id'))
Esempio n. 2
0
 def _dict_to_obj(cls, json_dict):
     rules = []
     for rule in json_dict.get('rules'):
         rules.append(SecurityGroupRule._dict_to_obj(rule))
     return SecurityGroup(id=json_dict.get('id'),
                          name=json_dict.get('name'),
                          description=json_dict.get('description'),
                          rules=rules,
                          tenant_id=json_dict.get('tenant_id'))
Esempio n. 3
0
 def _xml_ele_to_obj(cls, xml_ele):
     id = xml_ele.attrib.get('id')
     tenant_id = xml_ele.attrib.get('tenant_id')
     name = xml_ele.attrib.get('name')
     description = xml_ele.find('description').text
     rules = []
     for rule in xml_ele.find('rules').findall('rule'):
         rules.append(SecurityGroupRule._xml_ele_to_obj(rule))
     return SecurityGroup(id=id, name=name,
                          description=description,
                          rules=rules,
                          tenant_id=tenant_id)
Esempio n. 4
0
 def _xml_ele_to_obj(cls, xml_ele):
     id = xml_ele.attrib.get('id')
     tenant_id = xml_ele.attrib.get('tenant_id')
     name = xml_ele.attrib.get('name')
     description = xml_ele.find('description').text
     rules = []
     for rule in xml_ele.find('rules').findall('rule'):
         rules.append(SecurityGroupRule._xml_ele_to_obj(rule))
     return SecurityGroup(id=id,
                          name=name,
                          description=description,
                          rules=rules,
                          tenant_id=tenant_id)
Esempio n. 5
0
 def setUpClass(cls):
     cls.sec_group_rule_json = ('{"security_group_rule":'
                                ' {"from_port": 80,'
                                '"group": {},'
                                '"ip_protocol": "tcp",'
                                '"to_port": 8080,'
                                '"parent_group_id":'
                                ' "b32c047d-5efc-42ab-8476-3ac9f3681af2",'
                                '"ip_range": {"cidr": "0.0.0.0/0"},'
                                '"id":'
                                ' "bf57c853-cdf2-4c99-9f9a-79b3e9dc13a8"}}')
     cls.sec_group_rule = (SecurityGroupRule.deserialize(
         cls.sec_group_rule_json, "json"))
Esempio n. 6
0
 def setUpClass(cls):
     cls.sec_group_rule_xml = ('<?xml version="1.0" encoding="UTF-8"?>'
                               '<security_group_rule'
                               ' xmlns='
                               '"http://docs.openstack.org/'
                               'compute/api/v1.1"'
                               ' parent_group_id='
                               '"b32c047d-5efc-42ab-8476-3ac9f3681af2"'
                               ' id="bf57c853-cdf2-4c99-9f9a-79b3e9dc13a8">'
                               '<ip_protocol>tcp</ip_protocol>'
                               '<from_port>80</from_port>'
                               '<to_port>8080</to_port>'
                               '<group>'
                               '<name>None</name>'
                               '<tenant_id>None</tenant_id>'
                               '</group>'
                               '<ip_range>'
                               '<cidr>0.0.0.0/0</cidr>'
                               '</ip_range>'
                               '</security_group_rule>')
     cls.sec_group_rule = (SecurityGroupRule.deserialize(
         cls.sec_group_rule_xml, "xml"))