def _security_group_rule_append(self, sg_obj, sg_rule):
        rules = sg_obj.get_security_group_entries()
        if rules is None:
            rules = PolicyEntriesType([sg_rule])
        else:
            for sgr in rules.get_policy_rule() or []:
                sgr_copy = copy.copy(sgr)
                sgr_copy.rule_uuid = sg_rule.rule_uuid
                if sg_rule == sgr_copy:
                    raise Exception('SecurityGroupRuleExists %s' % sgr.rule_uuid)
            rules.add_policy_rule(sg_rule)

        sg_obj.set_security_group_entries(rules)
Beispiel #2
0
    def _security_group_rule_append(self, sg_obj, sg_rule):
        rules = sg_obj.get_security_group_entries()
        if rules is None:
            rules = PolicyEntriesType([sg_rule])
        else:
            for sgr in rules.get_policy_rule() or []:
                sgr_copy = copy.copy(sgr)
                sgr_copy.rule_uuid = sg_rule.rule_uuid
                if sg_rule == sgr_copy:
                    raise Exception('SecurityGroupRuleExists %s' % sgr.rule_uuid)
            rules.add_policy_rule(sg_rule)

        sg_obj.set_security_group_entries(rules)
 def _create_vn_vn_policy(self, policy_name, \
         proj_obj, src_vn_obj, dst_vn_obj):
     policy_exists = False
     policy = NetworkPolicy(name=policy_name, parent_obj=proj_obj)
     try:
         policy_obj = self._vnc_lib.network_policy_read(
             fq_name=policy.get_fq_name())
         policy_exists = True
     except NoIdError:
         # policy does not exist. Create one.
         policy_obj = policy
     network_policy_entries = PolicyEntriesType()
     policy_entry = self._create_policy_entry(src_vn_obj, dst_vn_obj)
     network_policy_entries.add_policy_rule(policy_entry)
     policy_obj.set_network_policy_entries(network_policy_entries)
     if policy_exists:
         self._vnc_lib.network_policy_update(policy)
     else:
         self._vnc_lib.network_policy_create(policy)
     return policy_obj
 def _create_vn_vn_policy(self, policy_name,
         proj_obj, src_vn_obj, dst_vn_obj):
     policy_exists = False
     policy = NetworkPolicy(name=policy_name, parent_obj=proj_obj)
     try:
         policy_obj = self._vnc_lib.network_policy_read(
             fq_name=policy.get_fq_name())
         policy_exists = True
     except NoIdError:
         # policy does not exist. Create one.
         policy_obj = policy
     network_policy_entries = PolicyEntriesType()
     policy_entry = self._create_policy_entry(src_vn_obj, dst_vn_obj)
     network_policy_entries.add_policy_rule(policy_entry)
     policy_obj.set_network_policy_entries(network_policy_entries)
     if policy_exists:
         self._vnc_lib.network_policy_update(policy)
     else:
         self._vnc_lib.network_policy_create(policy)
     return policy_obj