-
- def new_external_port(self, port_data):
- #TODO openstack if needed
- '''Adds a external port to VIM'''
- '''Returns the port identifier'''
- return -vimconn.HTTP_Internal_Server_Error, "osconnector.new_external_port() not implemented"
-
- def connect_port_network(self, port_id, network_id, admin=False):
- #TODO openstack if needed
- '''Connects a external port to a network'''
- '''Returns status code of the VIM response'''
- return -vimconn.HTTP_Internal_Server_Error, "osconnector.connect_port_network() not implemented"
-
- def new_user(self, user_name, user_passwd, tenant_id=None):
- '''Adds a new user to openstack VIM'''
- '''Returns the user identifier'''
- if self.debug:
- print "osconnector: Adding a new user to VIM"
- try:
- self._reload_connection()
- user=self.keystone.users.create(user_name, user_passwd, tenant_id=tenant_id)
- #self.keystone.tenants.add_user(self.k_creds["username"], #role)
- return 1, user.id
- except ksExceptions.ConnectionError as e:
- error_value=-vimconn.HTTP_Bad_Request
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- except ksExceptions.ClientException as e: #TODO remove
- error_value=-vimconn.HTTP_Bad_Request
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- #TODO insert exception vimconn.HTTP_Unauthorized
- #if reaching here is because an exception
- if self.debug:
- print "new_tenant " + error_text
- return error_value, error_text
-
- def delete_user(self, user_id):
- '''Delete a user from openstack VIM'''
- '''Returns the user identifier'''
- if self.debug:
- print "osconnector: Deleting a user from VIM"
- try:
- self._reload_connection()
- self.keystone.users.delete(user_id)
- return 1, user_id
- except ksExceptions.ConnectionError as e:
- error_value=-vimconn.HTTP_Bad_Request
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- except ksExceptions.NotFound as e:
- error_value=-vimconn.HTTP_Not_Found
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- except ksExceptions.ClientException as e: #TODO remove
- error_value=-vimconn.HTTP_Bad_Request
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- #TODO insert exception vimconn.HTTP_Unauthorized
- #if reaching here is because an exception
- if self.debug:
- print "delete_tenant " + error_text
- return error_value, error_text
-
- def new_tenant(self,tenant_name,tenant_description):
- '''Adds a new tenant to openstack VIM'''
- '''Returns the tenant identifier'''
- if self.debug:
- print "osconnector: Adding a new tenant to VIM"
- try:
- self._reload_connection()
- tenant=self.keystone.tenants.create(tenant_name, tenant_description)
- #self.keystone.tenants.add_user(self.k_creds["username"], #role)
- return 1, tenant.id
- except ksExceptions.ConnectionError as e:
- error_value=-vimconn.HTTP_Bad_Request
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- except ksExceptions.ClientException as e: #TODO remove
- error_value=-vimconn.HTTP_Bad_Request
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- #TODO insert exception vimconn.HTTP_Unauthorized
- #if reaching here is because an exception
- if self.debug:
- print "new_tenant " + error_text
- return error_value, error_text
-
- def delete_tenant(self,tenant_id):
- '''Delete a tenant from openstack VIM'''
- '''Returns the tenant identifier'''
- if self.debug:
- print "osconnector: Deleting a tenant from VIM"
- try:
- self._reload_connection()
- self.keystone.tenants.delete(tenant_id)
- #self.keystone.tenants.add_user(self.k_creds["username"], #role)
- return 1, tenant_id
- except ksExceptions.ConnectionError as e:
- error_value=-vimconn.HTTP_Bad_Request
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- except ksExceptions.ClientException as e: #TODO remove
- error_value=-vimconn.HTTP_Bad_Request
- error_text= type(e).__name__ + ": "+ (str(e) if len(e.args)==0 else str(e.args[0]))
- #TODO insert exception vimconn.HTTP_Unauthorized
- #if reaching here is because an exception
- if self.debug:
- print "delete_tenant " + error_text
- return error_value, error_text