• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vnc_api.VncApi类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vnc_api.vnc_api.VncApi的典型用法代码示例。如果您正苦于以下问题:Python VncApi类的具体用法?Python VncApi怎么用?Python VncApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了VncApi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: restart_dhcp_server

 def restart_dhcp_server(cls, file_name, fabric_name, job_ctx):
     vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                      auth_token=job_ctx.get('auth_token'))
     headers = {
         'fabric_name': fabric_name,
         'file_name': file_name,
         'action': 'delete'
     }
     vnc_api.amqp_publish(exchange=cls.ZTP_EXCHANGE,
         exchange_type=cls.ZTP_EXCHANGE_TYPE,
         routing_key=cls.ZTP_REQUEST_ROUTING_KEY, headers=headers,
         payload={})
     return { 'status': 'success' }
开发者ID:Juniper,项目名称:contrail-controller,代码行数:13,代码来源:ztp_filters.py


示例2: _publish_file

 def _publish_file(cls, name, contents, action, routing_key,
                   fabric_name, job_ctx):
     vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                      auth_token=job_ctx.get('auth_token'))
     headers = {
         'fabric_name': fabric_name,
         'file_name': name,
         'action': action
     }
     vnc_api.amqp_publish(exchange=cls.ZTP_EXCHANGE,
         exchange_type=cls.ZTP_EXCHANGE_TYPE,
         routing_key=routing_key, headers=headers,
         payload=contents)
     return { 'status': 'success' }
开发者ID:Juniper,项目名称:contrail-controller,代码行数:14,代码来源:ztp_filters.py


示例3: __init__

    def __init__(self):
        admin_user = cfg.CONF.keystone_authtoken.admin_user
        admin_password = cfg.CONF.keystone_authtoken.admin_password
        admin_tenant_name = cfg.CONF.keystone_authtoken.admin_tenant_name
        api_srvr_ip = cfg.CONF.APISERVER.api_server_ip
        api_srvr_port = cfg.CONF.APISERVER.api_server_port
        api_srvr_use_ssl= cfg.CONF.APISERVER.use_ssl
        try:
            auth_host = cfg.CONF.keystone_authtoken.auth_host
        except cfg.NoSuchOptError:
            auth_host = "127.0.0.1"

        try:
            auth_protocol = cfg.CONF.keystone_authtoken.auth_protocol
        except cfg.NoSuchOptError:
            auth_protocol = "http"

        try:
            auth_port = cfg.CONF.keystone_authtoken.auth_port
        except cfg.NoSuchOptError:
            auth_port = "35357"

        try:
            auth_url = cfg.CONF.keystone_authtoken.auth_url
        except cfg.NoSuchOptError:
            auth_url = "/v2.0/tokens"

        try:
            auth_type = cfg.CONF.keystone_authtoken.auth_type
        except cfg.NoSuchOptError:
            auth_type = "keystone"

        try:
            api_server_url = cfg.CONF.APISERVER.api_server_url
        except cfg.NoSuchOptError:
            api_server_url = "/"

        # Retry till a api-server is up
        connected = False
        while not connected:
            try:
                self._api = VncApi(admin_user, admin_password, admin_tenant_name,
                                   api_srvr_ip, api_srvr_port, api_server_url,
                                   auth_host=auth_host, auth_port=auth_port,
                                   auth_protocol=auth_protocol, auth_url=auth_url,
                                   auth_type=auth_type, wait_for_connect=True,
                                   api_server_use_ssl=api_srvr_use_ssl)
                connected = True
            except requests.exceptions.RequestException:
                time.sleep(3)

        self._pool_manager = \
            loadbalancer_pool.LoadbalancerPoolManager(self._api)
        self._vip_manager = virtual_ip.VirtualIpManager(self._api)
        self._member_manager = \
            loadbalancer_member.LoadbalancerMemberManager(self._api)
        self._monitor_manager = \
            loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager(
                self._api)
开发者ID:tcpcloud,项目名称:contrail-neutron-plugin,代码行数:59,代码来源:loadbalancer_db.py


示例4: read_dhcp_leases

 def read_dhcp_leases(cls, ipam_subnets, file_name, fabric_name, job_ctx,
                      payload_key, payload_value, action='create'):
     vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                      auth_token=job_ctx.get('auth_token'))
     headers = {
         'fabric_name': fabric_name,
         'file_name': file_name,
         'action': action
     }
     payload = {
         'ipam_subnets': ipam_subnets
     }
     payload[payload_key] = payload_value
     return vnc_api.amqp_request(exchange=cls.ZTP_EXCHANGE,
         exchange_type=cls.ZTP_EXCHANGE_TYPE,
         routing_key=cls.ZTP_REQUEST_ROUTING_KEY,
         response_key=cls.ZTP_RESPONSE_ROUTING_KEY + fabric_name,
         headers=headers, payload=payload)
开发者ID:Juniper,项目名称:contrail-controller,代码行数:18,代码来源:ztp_filters.py


示例5: __init__

 def __init__(self, user, passwd, project_name, inputs, domain='default-domain'):
     self.inputs = inputs
     self.user = user
     self.passwd = passwd
     self.domain = domain
     self.project_name = project_name
     self.vnc = VncApi(username=user, password=passwd,
                       tenant_name=project_name,
                       api_server_host=self.inputs.cfgm_ip,
                       api_server_port=self.inputs.api_server_port)
开发者ID:aswanikumar90,项目名称:contrail-test,代码行数:10,代码来源:vcenter.py


示例6: get_ztp_dhcp_config

    def get_ztp_dhcp_config(cls, job_ctx, fabric_uuid):
        dhcp_config = {}
        try:
            vncapi = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                            auth_token=job_ctx.get('auth_token'))
            fabric = vncapi.fabric_read(id=fabric_uuid)
            fabric_dict = vncapi.obj_to_dict(fabric)

            # From here we get the 'management' type virtual network
            vn_uuid = None
            virtual_network_refs = fabric_dict.get('virtual_network_refs') or []
            for virtual_net_ref in virtual_network_refs:
                if 'management' in virtual_net_ref['attr']['network_type']:
                    vn_uuid = virtual_net_ref['uuid']
                    break
            if vn_uuid is None:
                raise NoIdError("Cannot find mgmt virtual network on fabric")

            virtual_net = vncapi.virtual_network_read(id=vn_uuid)
            virtual_net_dict = vncapi.obj_to_dict(virtual_net)

            # Get the IPAM attached to the virtual network
            ipam_refs = virtual_net_dict.get('network_ipam_refs')
            if ipam_refs:
                ipam_ref = ipam_refs[0]
                ipam = vncapi.network_ipam_read(id=ipam_ref['uuid'])
                ipam_dict = vncapi.obj_to_dict(ipam)
                ipam_subnets = ipam_dict.get('ipam_subnets')
                if ipam_subnets:
                    dhcp_config['ipam_subnets'] = ipam_subnets.get('subnets')

            # Get static ip configuration for physical routers
            pr_refs = fabric.get_physical_router_back_refs()
            pr_uuids = [ref['uuid'] for ref in pr_refs]
            static_ips = {}
            for pr_uuid in pr_uuids:
                pr = vncapi.physical_router_read(id=pr_uuid)
                pr_dict = vncapi.obj_to_dict(pr)
                mac = pr_dict.get('physical_router_management_mac')
                ip = pr_dict.get('physical_router_management_ip')
                if mac and ip:
                    static_ips[ip] = mac
            if static_ips:
                dhcp_config['static_ips'] = static_ips
        except Exception as ex:
            logging.error("Error getting ZTP DHCP configuration: {}".format(ex))

        return dhcp_config
开发者ID:Juniper,项目名称:contrail-controller,代码行数:48,代码来源:ztp_filters.py


示例7: __init__

 def __init__(self):
     # TODO: parse configuration for api-server:port and auth
     self._api = VncApi()
     self._pool_manager = \
         loadbalancer_pool.LoadbalancerPoolManager(self._api)
     self._vip_manager = virtual_ip.VirtualIpManager(self._api)
     self._member_manager = \
         loadbalancer_member.LoadbalancerMemberManager(self._api)
     self._monitor_manager = \
         loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager(
             self._api)
开发者ID:achanda,项目名称:contrail-neutron-plugin,代码行数:11,代码来源:loadbalancer_db.py


示例8: get_pr_subnet

    def get_pr_subnet(cls, job_ctx, fabric_uuid, device_fq_name):
        api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                     auth_token=job_ctx.get('auth_token'))
        fabric = api.fabric_read(id=fabric_uuid)
        fabric_dict = api.obj_to_dict(fabric)

        vn_uuid = None
        virtual_network_refs = fabric_dict.get('virtual_network_refs') or []
        for virtual_net_ref in virtual_network_refs:
            if 'management' in virtual_net_ref['attr']['network_type']:
                vn_uuid = virtual_net_ref['uuid']
                break
        if vn_uuid is None:
            raise NoIdError("Cannot find mgmt virtual network on fabric")

        virtual_net = api.virtual_network_read(id=vn_uuid)
        virtual_net_dict = api.obj_to_dict(virtual_net)

        subnets = None
        ipam_refs = virtual_net_dict.get('network_ipam_refs')
        if ipam_refs:
            ipam_ref = ipam_refs[0]
            ipam = api.network_ipam_read(id=ipam_ref['uuid'])
            ipam_dict = api.obj_to_dict(ipam)
            ipam_subnets = ipam_dict.get('ipam_subnets')
            if ipam_subnets:
                subnets = ipam_subnets.get('subnets')

        gateway = None
        cidr = None
        if subnets:
            pr = api.physical_router_read(fq_name=device_fq_name)
            pr_dict = api.obj_to_dict(pr)
            ip = pr_dict.get('physical_router_management_ip')
            ip_addr = IPAddress(ip)
            for subnet in subnets:
                inner_subnet = subnet.get('subnet')
                cidr = inner_subnet.get('ip_prefix') + '/' + str(inner_subnet.get('ip_prefix_len'))
                if ip_addr in IPNetwork(cidr) and subnet.get('default_gateway'):
                    gateway = subnet.get('default_gateway')
                    break
        if cidr and gateway:
            return { 'cidr': cidr, 'gateway': gateway }

        raise Error("Cannot find cidr and gateway for device: %s" % str(device_fq_name))
开发者ID:Juniper,项目名称:contrail-controller,代码行数:45,代码来源:physical_router_filters.py


示例9: get_ztp_tftp_config

    def get_ztp_tftp_config(cls, job_ctx, fabric_uuid):
        tftp_config = {}
        try:
            vncapi = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                            auth_token=job_ctx.get('auth_token'))
            fabric = vncapi.fabric_read(id=fabric_uuid)
            fabric_dict = vncapi.obj_to_dict(fabric)
            fabric_creds = fabric_dict.get('fabric_credentials')
            if fabric_creds:
                device_creds = fabric_creds.get('device_credential')
                if device_creds:
                    dev_cred = device_creds[0]
                    password = JobVncApi.decrypt_password(
                        encrypted_password=dev_cred['credential']['password'],
                        admin_password=job_ctx.get(
                            'vnc_api_init_params').get(
                            'admin_password'))
                    tftp_config['password'] = password
        except Exception as ex:
            logging.error("Error getting ZTP TFTP configuration: {}".format(ex))

        return tftp_config
开发者ID:Juniper,项目名称:contrail-controller,代码行数:22,代码来源:ztp_filters.py


示例10: __init__

 def __init__(self):
     admin_user = cfg.CONF.keystone_authtoken.admin_user
     admin_password = cfg.CONF.keystone_authtoken.admin_password
     admin_tenant_name = cfg.CONF.keystone_authtoken.admin_tenant_name
     api_srvr_ip = cfg.CONF.APISERVER.api_server_ip
     api_srvr_port = cfg.CONF.APISERVER.api_server_port
     self._api = VncApi(admin_user, admin_password, admin_tenant_name,
                        api_srvr_ip, api_srvr_port,api_auth_protocol="https")
     self._pool_manager = \
         loadbalancer_pool.LoadbalancerPoolManager(self._api)
     self._vip_manager = virtual_ip.VirtualIpManager(self._api)
     self._member_manager = \
         loadbalancer_member.LoadbalancerMemberManager(self._api)
     self._monitor_manager = \
         loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager(
             self._api)
开发者ID:CodeWire,项目名称:Standup-a-3-node-OpenStack-HA-Controller-Cluster-with-Contrail-SDN,代码行数:16,代码来源:loadbalancer_db.py


示例11: main

def main():
    client=VncApi()
    virtual_networks=client.virtual_networks_list()
    virtual_machine_interfaces=client.virtual_machine_interfaces_list()
    virtual_machines=client.virtual_machines_list()
    instance_ips=client.instance_ips_list()
    projects=client.projects_list()
    domains=client.domains_list()
    floating_ip_pools=client.floating_ip_pools_list()
    access_control_lists=client.access_control_lists_list()
    print domains
    for project in projects['projects']:
        id=project['uuid']
        name=project['fq_name']
        print id,name
    print projects
    print virtual_networks
    print virtual_machine_interfaces
    print virtual_machines
    print instance_ips
    print  access_control_lists
    print  floating_ip_pools
开发者ID:Doude,项目名称:contrail-installer,代码行数:22,代码来源:test_domainlist.py


示例12: __init__

    def __init__(self, cfg, name):
        if cfg is None:
            raise KeyError("Missing required args: cfg")
        if name is None:
            raise KeyError("Missing required args: name")

        self._name = name
        self._timeout = cfg['wait_for_job']['timeout']
        self._max_retries = cfg['wait_for_job']['max_retries']
        self._logger = SanityBase._init_logging(cfg['log'], name)
        self._api_server = cfg['api_server']
        self._analytics = cfg['analytics']
        self._api = VncApi(
            api_server_host=self._api_server['host'],
            api_server_port=self._api_server['port'],
            username=self._api_server['username'],
            password=self._api_server['password'],
            tenant_name=self._api_server['tenant'])
开发者ID:Juniper,项目名称:contrail-controller,代码行数:18,代码来源:sanity_base.py


示例13: VcenterAuth

class VcenterAuth(OrchestratorAuth):

    def __init__(self, user, passwd, project_name, inputs, domain='default-domain'):
        self.inputs = inputs
        self.user = user
        self.passwd = passwd
        self.domain = domain
        self.project_name = project_name
        use_ssl = self.inputs.api_protocol == 'https'
        self.vnc = VncApi(username=user, password=passwd,
                          tenant_name=project_name,
                          api_server_host=self.inputs.cfgm_ip,
                          api_server_port=self.inputs.api_server_port,
                          api_server_use_ssl=use_ssl)

    def get_project_id(self, project_name=None, domain_id=None):
       if not project_name:
           project_name = self.project_name
       fq_name = [unicode(self.domain), unicode(project_name)]
       obj = self.vnc.project_read(fq_name=fq_name)
       if obj:
           return obj.get_uuid()
       return None

    def reauth(self):
        raise Exception('Unimplemented interface')

    def create_project(self, name):
        raise Exception('Unimplemented interface')

    def delete_project(self, name):
        raise Exception('Unimplemented interface')

    def create_user(self, user, passwd):
        raise Exception('Unimplemented interface')

    def delete_user(self, user):
        raise Exception('Unimplemented interface')

    def add_user_to_project(self, user, project):
        raise Exception('Unimplemented interface')
开发者ID:Ankitja,项目名称:contrail-test,代码行数:41,代码来源:vcenter.py


示例14: get_ztp_config

    def get_ztp_config(cls, job_ctx, fabric_uuid):
        ztp_config = {}
        try:
            vncapi = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                            auth_token=job_ctx.get('auth_token'))
            fabric = vncapi.fabric_read(id=fabric_uuid)
            fabric_dict = vncapi.obj_to_dict(fabric)
            fabric_creds = fabric_dict.get('fabric_credentials')
            if fabric_creds:
                device_creds = fabric_creds.get('device_credential')
                if device_creds:
                    dev_cred = device_creds[0]
                    ztp_config['password'] = dev_cred['credential']['password']

            # From here we get the 'management' type virtual network
            vn_uuid = None
            virtual_network_refs = fabric_dict.get('virtual_network_refs') or []
            for virtual_net_ref in virtual_network_refs:
                if "management" in virtual_net_ref['attr']['network_type']:
                    vn_uuid = virtual_net_ref['uuid']
                    break
            if vn_uuid is None:
                raise NoIdError("Cannot find mgmt virtual network on fabric")

            virtual_net = vncapi.virtual_network_read(id=vn_uuid)
            virtual_net_dict = vncapi.obj_to_dict(virtual_net)

            # Get the IPAM attached to the virtual network
            ipam_refs = virtual_net_dict.get('network_ipam_refs')
            if ipam_refs:
                ipam_ref = ipam_refs[0]
                ipam = vncapi.network_ipam_read(id=ipam_ref['uuid'])
                ipam_dict = vncapi.obj_to_dict(ipam)
                ipam_subnets = ipam_dict.get('ipam_subnets')
                if ipam_subnets:
                    ztp_config['ipam_subnets'] = ipam_subnets.get('subnets')
        except NoIdError:
            logging.error("Cannot find mgmt virtual network")
        except Exception as ex:
            logging.error("Error getting ZTP configuration: {}".format(ex))

        return ztp_config
开发者ID:rombie,项目名称:contrail-controller,代码行数:42,代码来源:ztp_filters.py


示例15: SanityBase

class SanityBase(object):
    """Base class for fabric ansible sanity tests"""

    @staticmethod
    def _init_logging(cfg, name):
        logger = logging.getLogger('sanity_test')
        logger.setLevel(cfg['level'])

        file_handler = logging.FileHandler(
            '%s/fabric_ansibile_%s.log' % (cfg['file']['dir'], name), mode='w')
        file_handler.setLevel(cfg['file']['level'])
        console_handler = logging.StreamHandler()
        console_handler.setLevel(cfg['console'])

        formatter = logging.Formatter(
            '%(asctime)s %(levelname)-8s %(message)s',
            datefmt='%Y/%m/%d %H:%M:%S')
        file_handler.setFormatter(formatter)
        console_handler.setFormatter(formatter)
        logger.addHandler(file_handler)
        logger.addHandler(console_handler)

        return logger
    # end _init_logging

    def test(self):
        """Override this method in the derived class"""
        pass

    def __init__(self, cfg, name):
        if cfg is None:
            raise KeyError("Missing required args: cfg")
        if name is None:
            raise KeyError("Missing required args: name")

        self._name = name
        self._timeout = cfg['wait_for_job']['timeout']
        self._max_retries = cfg['wait_for_job']['max_retries']
        self._logger = SanityBase._init_logging(cfg['log'], name)
        self._api_server = cfg['api_server']
        self._analytics = cfg['analytics']
        self._api = VncApi(
            api_server_host=self._api_server['host'],
            api_server_port=self._api_server['port'],
            username=self._api_server['username'],
            password=self._api_server['password'],
            tenant_name=self._api_server['tenant'])
    # end __init__

    def create_fabric(self, fab_name, prouter_passwords):
        """create fabric with list of device passwords"""
        self._logger.info('Creating fabric: %s', fab_name)
        fq_name = ['default-global-system-config', fab_name]
        fab = Fabric(
            name=fab_name,
            fq_name=fq_name,
            parent_type='global-system-config',
            fabric_credentials={
                'device_credential': [{
                    'credential': {
                        'username': 'root', 'password': passwd
                    },
                    'vendor': 'Juniper',
                    'device_family': None
                } for passwd in prouter_passwords]
            }
        )
        try:
            fab_uuid = self._api.fabric_create(fab)
            fab = self._api.fabric_read(id=fab_uuid)
        except RefsExistError:
            self._logger.warn("Fabric '%s' already exists", fab_name)
            fab = self._api.fabric_read(fq_name=fq_name)

        self._logger.debug(
            "Fabric created:\n%s",
            pprint.pformat(self._api.obj_to_dict(fab), indent=4))
        return fab
    # end _create_fabric

    def add_mgmt_ip_namespace(self, fab, name, cidrs):
        """add management ip prefixes as fabric namespace"""
        ns_name = 'mgmt_ip-' + name
        self._logger.info(
            'Adding management ip namespace "%s" to fabric "%s" ...',
            ns_name, fab.name)

        subnets = []
        for cidr in cidrs:
            ip_prefix = cidr.split('/')
            subnets.append({
                'ip_prefix': ip_prefix[0],
                'ip_prefix_len': ip_prefix[1]
            })
        ns_fq_name = fab.fq_name + [ns_name]
        namespace = FabricNamespace(
            name=ns_name,
            fq_name=ns_fq_name,
            parent_type='fabric',
            fabric_namespace_type='IPV4-CIDR',
#.........这里部分代码省略.........
开发者ID:Juniper,项目名称:contrail-controller,代码行数:101,代码来源:sanity_base.py


示例16: LoadBalancerPluginDb

class LoadBalancerPluginDb(LoadBalancerPluginBase):

    def __init__(self):
        admin_user = cfg.CONF.keystone_authtoken.admin_user
        admin_password = cfg.CONF.keystone_authtoken.admin_password
        admin_tenant_name = cfg.CONF.keystone_authtoken.admin_tenant_name
        api_srvr_ip = cfg.CONF.APISERVER.api_server_ip
        api_srvr_port = cfg.CONF.APISERVER.api_server_port
        try:
            auth_host = cfg.CONF.keystone_authtoken.auth_host
        except cfg.NoSuchOptError:
            auth_host = "127.0.0.1"

        try:
            auth_protocol = cfg.CONF.keystone_authtoken.auth_protocol
        except cfg.NoSuchOptError:
            auth_protocol = "http"

        try:
            auth_port = cfg.CONF.keystone_authtoken.auth_port
        except cfg.NoSuchOptError:
            auth_port = "35357"

        try:
            auth_url = cfg.CONF.keystone_authtoken.auth_url
        except cfg.NoSuchOptError:
            auth_url = "/v2.0/tokens"

        try:
            auth_type = cfg.CONF.keystone_authtoken.auth_type
        except cfg.NoSuchOptError:
            auth_type = "keystone"

        try:
            api_server_url = cfg.CONF.APISERVER.api_server_url
        except cfg.NoSuchOptError:
            api_server_url = "/"

        # Retry till a api-server is up
        connected = False
        while not connected:
            try:
                self._api = VncApi(
                     admin_user, admin_password, admin_tenant_name,
                     api_srvr_ip, api_srvr_port, api_server_url,
                     auth_host=auth_host, auth_port=auth_port,
                     auth_protocol=auth_protocol, auth_url=auth_url,
                     api_auth_protocol="https")
                connected = True
            except requests.exceptions.RequestException as e:
                time.sleep(3)

        self._pool_manager = \
            loadbalancer_pool.LoadbalancerPoolManager(self._api)
        self._vip_manager = virtual_ip.VirtualIpManager(self._api)
        self._member_manager = \
            loadbalancer_member.LoadbalancerMemberManager(self._api)
        self._monitor_manager = \
            loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager(
                self._api)

    def get_api_client(self):
        return self._api

    def get_vips(self, context, filters=None, fields=None):
        return self._vip_manager.get_collection(context, filters, fields)

    def get_vip(self, context, id, fields=None):
        return self._vip_manager.get_resource(context, id, fields)

    def create_vip(self, context, vip):
        return self._vip_manager.create(context, vip)

    def update_vip(self, context, id, vip):
        return self._vip_manager.update(context, id, vip)

    def delete_vip(self, context, id):
        return self._vip_manager.delete(context, id)

    def get_pools(self, context, filters=None, fields=None):
        return self._pool_manager.get_collection(context, filters, fields)

    def get_pool(self, context, id, fields=None):
        return self._pool_manager.get_resource(context, id, fields)

    def create_pool(self, context, pool):
        return self._pool_manager.create(context, pool)

    def update_pool(self, context, id, pool):
        return self._pool_manager.update(context, id, pool)

    def delete_pool(self, context, id):
        return self._pool_manager.delete(context, id)

    def stats(self, context, pool_id):
        pass

    def create_pool_health_monitor(self, context, health_monitor, pool_id):
        """ Associate an health monitor with a pool.
        """
#.........这里部分代码省略.........
开发者ID:alfredcs,项目名称:Integrating-Docker-with-OpenStack-With-OpenContrail-For-SDN,代码行数:101,代码来源:loadbalancer_db.py


示例17: LoadBalancerPluginDb

class LoadBalancerPluginDb(LoadBalancerPluginBase):

    def __init__(self):
        # TODO: parse configuration for api-server:port and auth
        self._api = VncApi()
        self._pool_manager = \
            loadbalancer_pool.LoadbalancerPoolManager(self._api)
        self._vip_manager = virtual_ip.VirtualIpManager(self._api)
        self._member_manager = \
            loadbalancer_member.LoadbalancerMemberManager(self._api)
        self._monitor_manager = \
            loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager(
                self._api)

    def get_api_client(self):
        return self._api

    def get_vips(self, context, filters=None, fields=None):
        return self._vip_manager.get_collection(context, filters, fields)

    def get_vip(self, context, id, fields=None):
        return self._vip_manager.get_resource(context, id, fields)

    def create_vip(self, context, vip):
        return self._vip_manager.create(context, vip)

    def update_vip(self, context, id, vip):
        return self._vip_manager.update(context, id, vip)

    def delete_vip(self, context, id):
        return self._vip_manager.delete(context, id)

    def get_pools(self, context, filters=None, fields=None):
        return self._pool_manager.get_collection(context, filters, fields)

    def get_pool(self, context, id, fields=None):
        return self._pool_manager.get_resource(context, id, fields)

    def create_pool(self, context, pool):
        return self._pool_manager.create(context, pool)

    def update_pool(self, context, id, pool):
        return self._pool_manager.update(context, id, pool)

    def delete_pool(self, context, id):
        return self._pool_manager.delete(context, id)

    def stats(self, context, pool_id):
        pass

    def create_pool_health_monitor(self, context, health_monitor, pool_id):
        """ Associate an health monitor with a pool.
        """
        m = health_monitor['health_monitor']
        try:
            pool = self._api.loadbalancer_pool_read(id=pool_id)
        except NoIdError:
            raise loadbalancer.PoolNotFound(pool_id=pool_id)

        try:
            monitor = self._api.loadbalancer_healthmonitor_read(id=m['id'])
        except NoIdError:
            raise loadbalancer.HealthMonitorNotFound(monitor_id=m['id'])

        if not context.is_admin:
            tenant_id = context.tenant_id
            if tenant_id != pool.parent_uuid or \
                    tenant_id != monitor.parent_uuid:
                raise n_exc.NotAuthorized()

        pool_refs = monitor.get_loadbalancer_pool_back_refs()
        if pool_refs is not None:
            for ref in pool_refs:
                if ref['uuid'] == pool_id:
                    raise loadbalancer.PoolMonitorAssociationExists(
                        monitor_id=m['id'], pool_id=pool_id)

        pool.add_loadbalancer_healthmonitor(monitor)
        self._api.loadbalancer_pool_update(pool)

        res = {
            'id': monitor.uuid,
            'tenant_id': monitor.parent_uuid
        }
        return res

    def get_pool_health_monitor(self, context, id, pool_id, fields=None):
        """ Query a specific pool, health_monitor association.
        """
        try:
            pool = self._api.loadbalancer_pool_read(id=pool_id)
        except NoIdError:
            raise loadbalancer.PoolNotFound(pool_id=id)
        if not context.is_admin and context.tenant_id != pool.parent_uuid:
            raise loadbalancer.PoolNotFound(pool_id=id)

        in_list = False
        for mref in pool.get_loadbalancer_healthmonitor_refs():
            if mref['uuid'] == id:
                in_list = True
#.........这里部分代码省略.........
开发者ID:achanda,项目名称:contrail-neutron-plugin,代码行数:101,代码来源:loadbalancer_db.py


示例18: initial_processing

    def initial_processing(self, concurrent):
        self.serial_num_flag = False
        self.all_serial_num = []
        serial_num = []
        self.per_greenlet_percentage = None

        self.job_ctx['current_task_index'] = 2

        try:
            total_percent = self.job_ctx.get('playbook_job_percentage')
            if total_percent:
                total_percent = float(total_percent)

            # Calculate the total percentage of this entire greenlet based task
            # This will be equal to the percentage alloted to this task in the
            # weightage array off the total job percentage. For example:
            # if the task weightage array is [10, 85, 5] and total job %
            # is 95. Then the 2nd task's effective total percentage is 85% of
            # 95%
            total_task_percentage = self.module.calculate_job_percentage(
                self.job_ctx.get('total_task_count'),
                task_seq_number=self.job_ctx.get('current_task_index'),
                total_percent=total_percent,
                task_weightage_array=self.job_ctx.get(
                    'task_weightage_array'))[0]

            # Based on the number of greenlets spawned (i.e num of sub tasks)
            # split the total_task_percentage equally amongst the greenlets.
            self.logger.info("Number of greenlets: {} and total_percent: "
                             "{}".format(concurrent, total_task_percentage))
            self.per_greenlet_percentage = \
                self.module.calculate_job_percentage(
                    concurrent, total_percent=total_task_percentage)[0]
            self.logger.info("Per greenlet percent: "
                             "{}".format(self.per_greenlet_percentage))

            self.vncapi = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                                 auth_token=self.job_ctx.get('auth_token'))
        except Exception as ex:
            self.logger.info("Percentage calculation failed with error "
                             "{}".format(str(ex)))

        try:
            self.vncapi = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY,
                                 auth_token=self.job_ctx.get('auth_token'))
        except Exception as ex:
            self.module.results['failed'] = True
            self.module.results['msg'] = "Failed to connect to API server " \
                "due to error: %s"\
                % str(ex)
            self.module.exit_json(**self.module.results)

        # get credentials and serial number if greenfield
        if self.total_retry_timeout:
            # get device credentials
            fabric = self.vncapi.fabric_read(id=self.fabric_uuid)
            fabric_object = self.vncapi.obj_to_dict(fabric)
            self.credentials = fabric_object.get('fabric_credentials').get(
                'device_credential')

            # get serial numbers
            fabric_namespace_obj_list = self.vncapi.fabric_namespaces_list(
                parent_id=self.fabric_uuid, detail=True)
            fabric_namespace_list = self.vncapi.obj_to_dict(
                fabric_namespace_obj_list)

            for namespace in fabric_namespace_list:
                if namespace.get('fabric_namespace_type') == "SERIAL_NUM":
                    self.serial_num_flag = True
                    serial_num.append(namespace.get(
                        'fabric_namespace_value').get('serial_num'))

            if len(serial_num) > 1:
                for outer_list in serial_num:
                    for sn in outer_list:
                        self.all_serial_num.append(sn)

        else:
            self.credentials = self.module.params['credentials']

        for cred in self.credentials:
            if cred.get('credential', {}).get('password'):
                cred['credential']['password'] = JobVncApi.decrypt_password(
                    encrypted_password=cred.get('credential', {}).get('password'),
                    admin_password=self.job_ctx.get('vnc_api_init_params').get(
                        'admin_password'))
开发者ID:Juniper,项目名称:contrail-controller,代码行数:86,代码来源:device_info.py


示例19: LoadBalancerPluginDb

class LoadBalancerPluginDb(LoadBalancerPluginBase):

    def __init__(self):
        admin_user = cfg.CONF.keystone_authtoken.admin_user
        admin_password = cfg.CONF.keystone_authtoken.admin_password
        admin_tenant_name = cfg.CONF.keystone_authtoken.admin_tenant_name
        api_srvr_ip = cfg.CONF.APISERVER.api_server_ip
        api_srvr_port = cfg.CONF.APISERVER.api_server_port
        api_srvr_use_ssl= cfg.CONF.APISERVER.use_ssl
        try:
            auth_host = cfg.CONF.keystone_authtoken.auth_host
        except cfg.NoSuchOptError:
            auth_host = "127.0.0.1"

        try:
            auth_protocol = cfg.CONF.keystone_authtoken.auth_protocol
        except cfg.NoSuchOptError:
            auth_protocol = "http"

        try:
            auth_port = cfg.CONF.keystone_authtoken.auth_port
        except cfg.NoSuchOptError:
            auth_port = "35357"

        try:
            auth_url = cfg.CONF.keystone_authtoken.auth_url
        except cfg.NoSuchOptError:
            auth_url = "/v2.0/tokens"

        try:
            auth_type = cfg.CONF.keystone_authtoken.auth_type
        except cfg.NoSuchOptError:
            auth_type = "keystone"

        try:
            api_server_url = cfg.CONF.APISERVER.api_server_url
        except cfg.NoSuchOptError:
            api_server_url = "/"

        # Retry till a api-server is up
        connected = False
        while not connected:
            try:
                self._api = VncApi(admin_user, admin_password, admin_tenant_name,
                                   api_srvr_ip, api_srvr_port, api_server_url,
                                   auth_host=auth_host, auth_port=auth_port,
                                   auth_protocol=auth_protocol, auth_url=auth_url,
                                   auth_type=auth_type, wait_for_connect=True,
                                   api_server_use_ssl=api_srvr_use_ssl)
                connected = True
            except requests.exceptions.RequestException:
                time.sleep(3)

        self._pool_manager = \
            loadbalancer_pool.LoadbalancerPoolManager(self._api)
        self._vip_manager = virtual_ip.VirtualIpManager(self._api)
        self._member_manager = \
            loadbalancer_member.LoadbalancerMemberManager(self._api)
        self._monitor_manager = \
            loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager(
                self._api)

    def get_api_client(self):
        return self._api

    def get_vips(self, context, filters=None, fields=None):
        return self._vip_manager.get_collection(context, filters, fields)

    def get_vip(self, context, id, fields=None):
        return self._vip_manager.get_resource(context, id, fields)

    def create_vip(self, context, vip):
        try:
            return self._vip_manager.create(context, vip)
        except vnc_exc.PermissionDenied as ex:
            raise n_exc.BadRequest(resource='vip', msg=str(ex))

    def update_vip(self, context, id, vip):
        return self._vip_manager.update(context, id, vip)

    def delete_vip(self, context, id):
        return self._vip_manager.delete(context, id)

    def get_pools(self, context, filters=None, fields=None):
        return self._pool_manager.get_collection(context, filters, fields)

    def get_pool(self, context, id, fields=None):
        return self._pool_manager.get_resource(context, id, fields)

    def create_pool(self, context, pool):
        try:
            return self._pool_manager.create(context, pool)
        except vnc_exc.PermissionDenied as ex:
            raise n_exc.BadRequest(resource='pool', msg=str(ex))

    def update_pool(self, context, id, pool):
        return self._pool_manager.update(context, id, pool)

    def delete_pool(self, context, id):
        return self._pool_manager.delete(context, id)
#.........这里部分代码省略.........
开发者ID:tcpcloud,项目名称:contrail-neutron-plugin,代码行数:101,代码来源:loadbalancer_db.py


示例20: DeviceInfo

class DeviceInfo(object):
    output = {}

    def __init__(self, module):
        self.module = module
        self.logger = module.logger
        self.job_ctx = module.job_ctx
        self.fabric_uuid = module.params['fabric_uuid']
        self.total_retry_timeout = float(module.params['total_retry_timeout'])
        self._job_file_write = JobFileWrite(self.logger)

    def initial_processing(self, concurrent):
        self.serial_num_flag = False
        self.all_se 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vnc_kubernetes_config.VncKubernetesConfig类代码示例发布时间:2022-05-26
下一篇:
Python vnc_api.VirtualNetwork类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap