def create_security_group(self, name, description): try: sec_group = self.client.security_groups.create( name=name, description=description) return sec_group except nova_exceptions.ClientException as e: LOG.exception('Failed to create remote security group') raise exception.SecurityGroupCreationError(str(e))
def create_security_group(self, name, description): try: sec_group_body = {"security_group": {"name": name, "description": description}} sec_group = self.client.create_security_group(body=sec_group_body) return self._convert_to_nova_security_group_format( sec_group.get('security_group', sec_group)) except neutron_exceptions.NeutronClientException as e: LOG.exception('Failed to create remote security group') raise exception.SecurityGroupCreationError(str(e))
def create(cls, name, description, context): """Creates a new Security Group""" client = trove.common.remote.create_nova_client(context) try: sec_group = client.security_groups.create(name=name, description=description) except nova_exceptions.ClientException as e: LOG.exception('Failed to create remote security group') raise exception.SecurityGroupCreationError(str(e)) return RemoteSecurityGroup(security_group=sec_group)
def create_sec_group(cls, name, description, context): try: remote_sec_group = RemoteSecurityGroup.create( name, description, context) if not remote_sec_group: raise exception.SecurityGroupCreationError( "Failed to create Security Group") else: return cls.create(id=remote_sec_group.data()['id'], name=name, description=description, user=context.user, tenant_id=context.tenant) except exception.SecurityGroupCreationError as e: LOG.exception("Failed to create remote security group") raise e