def plugin_create_sec_group(self, context, sg): """ Security group create request """ try: cfgdb = self._get_user_cfgdb(context) sg_info = cfgdb.security_group_create(sg['resource']) return sg_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_delete_port(self, context, port): """ Port delete request """ try: cfgdb = self._get_user_cfgdb(context) cfgdb.port_delete(port['id']) LOG.debug("plugin_delete_port(): " + pformat(port['id'])) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_create_floatingip(self, context, floatingip): """ Floating IP create request """ try: cfgdb = self._get_user_cfgdb(context) net_info = cfgdb.floatingip_create(floatingip['resource']) return net_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_update_subnet(self, context, subnet): """ Subnet update request """ try: cfgdb = self._get_user_cfgdb(context) subnet_info = cfgdb.subnet_update(subnet['id'], subnet['resource']) return self._make_subnet_dict(subnet_info) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_update_port(self, context, port): """ Port update request """ try: cfgdb = self._get_user_cfgdb(context) net_info = cfgdb.port_update(port['id'], port['resource']) return net_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_delete_network(self, context, network): """ Network delete request """ try: cfgdb = self._get_user_cfgdb(context) cfgdb.network_delete(network['id']) LOG.debug("plugin_delete_network(): " + pformat(network['id'])) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_update_network(self, context, network): """ Network update request """ try: cfgdb = self._get_user_cfgdb(context) net_info = cfgdb.network_update(network['id'], network['resource']) return net_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_create_svc_instance(self, context, svc_instance): """ Service instance create request """ try: cfgdb = self._get_user_cfgdb(context) si_info = cfgdb.svc_instance_create(svc_instance['resource']) return si_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_create_route_table(self, context, route_table): """ Route table create request """ try: cfgdb = self._get_user_cfgdb(context) rt_info = cfgdb.route_table_create(route_table['resource']) return rt_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_create_policy(self, context, policy): """ Policy create request """ try: cfgdb = self._get_user_cfgdb(context) pol_info = cfgdb.policy_create(policy['resource']) return pol_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_get_sec_group_rule(self, context, sg_rule): """ Security group rule get request """ try: cfgdb = self._get_user_cfgdb(context) sg_rule_info = cfgdb.security_group_rule_read( context, sg_rule['id']) return sg_rule_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise
def plugin_delete_ipam(self, context, ipam): """ IPAM delete request """ try: cfgdb = self._get_user_cfgdb(context) cfgdb.ipam_delete(ipam['id']) LOG.debug("plugin_delete_ipam(): " + pformat(ipam['id'])) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_update_router(self, context, router): """ Router update request """ try: cfgdb = self._get_user_cfgdb(context) router_info = cfgdb.router_update(router['id'], router['resource']) return router_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_delete_router(self, context, router): """ Router delete request """ try: cfgdb = self._get_user_cfgdb(context) cfgdb.router_delete(router['id']) LOG.debug("plugin_delete_router(): " + pformat(router['id'])) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_delete_sec_group_rule(self, context, sg_rule): """ Security group rule delete request """ try: cfgdb = self._get_user_cfgdb(context) cfgdb.security_group_rule_delete(sg_rule['id']) LOG.debug("plugin_delete_sec_group_rule(): " + pformat(sg_rule['id'])) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_delete_svc_instance(self, context, svc_instance): """ Service instance delete request """ try: cfgdb = self._get_user_cfgdb(context) cfgdb.svc_instance_delete(svc_instance['id']) LOG.debug("plugin_delete_svc_instance(): " + pformat(svc_instance['id'])) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def cgitb_hook(info=None, **kwargs): buf = sys.stdout if 'file' in kwargs: buf = kwargs['file'] local_buf = cStringIO.StringIO() kwargs['file'] = local_buf cgitb.Hook(**kwargs).handle(info or sys.exc_info()) doc = local_buf.getvalue() local_buf.close() buf.write(mask_password(doc)) buf.flush()
def plugin_update_ipam(self, context, ipam): """ IPAM update request """ try: cfgdb = self._get_user_cfgdb(context) ipam_info = cfgdb.ipam_update(ipam['id'], ipam['resource']) return ipam_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_delete_floatingip(self, context, floatingip): """ Floating IP delete request """ try: cfgdb = self._get_user_cfgdb(context) cfgdb.floatingip_delete(floatingip['id']) LOG.debug("plugin_delete_floatingip(): " + pformat(floatingip['id'])) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_get_ipam(self, context, ipam): """ IPAM get request """ fields = ipam['fields'] try: cfgdb = self._get_user_cfgdb(context) ipam_info = cfgdb.ipam_read(ipam['id']) return ipam_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_get_router(self, context, router): """ Router get request """ fields = router['fields'] try: cfgdb = self._get_user_cfgdb(context) router_info = cfgdb.router_read(router['id']) return router_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_get_sec_group(self, context, sg): """ Security group get request """ fields = sg['fields'] try: cfgdb = self._get_user_cfgdb(context) sg_info = cfgdb.security_group_read(sg['id']) return sg_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def _del_domain_from_vnc(self, domain_id): if domain_id in self._failed_domain_dels: return try: self._vnc_lib.domain_delete(id=domain_id) except vnc_api.NoIdError: pass except Exception as e: cgitb.Hook(format="text", file=open(self._tmp_file_name, 'w')).handle(sys.exc_info()) fhandle = open(self._tmp_file_name) self._vnc_os_logger.error("%s" % fhandle.read()) self._failed_domain_dels.add(domain_id)
def plugin_get_floatingip(self, context, floatingip): """ Floating IP get request """ fields = floatingip['fields'] try: cfgdb = self._get_user_cfgdb(context) fip_info = cfgdb.floatingip_read(floatingip['id']) return fip_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_get_port(self, context, port): """ Port get request """ fields = port['fields'] try: cfgdb = self._get_user_cfgdb(context) port_info = cfgdb.port_read(port['id']) return port_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_get_subnet(self, context, subnet): """ Subnet get request """ fields = subnet['fields'] try: cfgdb = self._get_user_cfgdb(context) subnet_info = cfgdb.subnet_read(subnet['id']) return self._make_subnet_dict(subnet_info) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_get_network(self, context, network): """ Network get request """ fields = network['fields'] try: cfgdb = self._get_user_cfgdb(context) net_info = cfgdb.network_read(network['id'], fields) return net_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def plugin_get_ipams(self, context, ipam): """ IPAM get request """ filters = ipam['filters'] try: cfgdb = self._get_user_cfgdb(context) ipams_info = cfgdb.ipam_list(context, filters) return json.dumps(ipams_info) except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise
def plugin_get_svc_instance(self, context, svc_instance): """ Service instance get request """ fields = svc_instance['fields'] try: cfgdb = self._get_user_cfgdb(context) si_info = cfgdb.svc_instance_read(svc_instance['id']) return si_info except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e
def delete_tenant_quota(context, tenant_id): try: proj_id = str(uuid.UUID(tenant_id)) proj_obj = QuotaDriver._get_vnc_conn().project_read(id=proj_id) quota = proj_obj.get_quota() except Exception as e: cgitb.Hook(format="text").handle(sys.exc_info()) raise e for k, v in quota.__dict__.items(): if k != 'defaults': quota.__dict__[k] = quota.defaults proj_obj.set_quota(quota) QuotaDriver._get_vnc_conn().project_update(proj_obj)