예제 #1
0
    def schedule(self, context, topic, *args, **kwargs):
        """Gets the host name from the Quantum service"""
        instance_id = kwargs['instance_id']
        user_id = \
                kwargs['request_spec']['instance_properties']['user_id']
        project_id = \
                kwargs['request_spec']['instance_properties']['project_id']

        instance_data_dict = \
                {'novatenant': \
                 {'instance_id': instance_id,
                  'instance_desc': \
                  {'user_id': user_id,
                   'project_id': project_id}}}

        client = Client(HOST,
                        PORT,
                        USE_SSL,
                        format='json',
                        tenant=TENANT_ID,
                        action_prefix=ACTION_PREFIX_CSCO)
        request_url = "/novatenants/" + project_id + ACTION
        data = client.do_request('PUT', request_url, body=instance_data_dict)

        hostname = data["host_list"]["host_1"]
        if not hostname:
            raise driver.NoValidHost(
                _("Scheduler was unable to locate a host"
                  " for this request. Is the appropriate"
                  " service running?"))

        LOG.debug(_("Quantum service returned host: %s") % hostname)
        return hostname
예제 #2
0
파일: cli.py 프로젝트: BillTheBest/quantum
def list_extensions(*args):
    """Invoking the action to get the supported extensions"""
    request_url = "/extensions"
    client = Client(HOST, PORT, USE_SSL, format='json',
                    action_prefix=ACTION_PREFIX_EXT, tenant="dummy")
    data = client.do_request('GET', request_url)
    print("Obtained supported extensions from Quantum: %s" % data)
    def schedule(self, context, topic, *args, **kwargs):
        """Gets the host name from the Quantum service"""
        instance_id = kwargs['instance_id']
        user_id = \
                kwargs['request_spec']['instance_properties']['user_id']
        project_id = \
                kwargs['request_spec']['instance_properties']['project_id']

        instance_data_dict = \
                {'novatenant': \
                 {'instance_id': instance_id,
                  'instance_desc': \
                  {'user_id': user_id,
                   'project_id': project_id}}}

        client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID,
                        action_prefix=ACTION_PREFIX_CSCO)
        request_url = "/novatenants/" + project_id + ACTION
        data = client.do_request('PUT', request_url, body=instance_data_dict)

        hostname = data["host_list"]["host_1"]
        if not hostname:
            raise driver.NoValidHost(_("Scheduler was unable to locate a host"
                                       " for this request. Is the appropriate"
                                       " service running?"))

        LOG.debug(_("Quantum service returned host: %s") % hostname)
        return hostname
    def _schedule(self, context, topic, request_spec, **kwargs):
        """Gets the host name from the Quantum service"""
        LOG.debug("Cisco Quantum Port-aware Scheduler is scheduling...")
        instance_id = request_spec['instance_properties']['uuid']
        user_id = \
                request_spec['instance_properties']['user_id']
        project_id = \
                request_spec['instance_properties']['project_id']

        instance_data_dict = \
                {'novatenant': \
                 {'instance_id': instance_id,
                  'instance_desc': \
                  {'user_id': user_id,
                   'project_id': project_id}}}

        client = Client(HOST, PORT, USE_SSL, format='json', version=VERSION,
                        uri_prefix=URI_PREFIX_CSCO, tenant=TENANT_ID,
                        logger=LOG)
        request_url = "/novatenants/" + project_id + ACTION
        data = client.do_request('PUT', request_url, body=instance_data_dict)

        hostname = data["host_list"]["host_1"]
        if not hostname:
            raise excp.NoValidHost(_("Scheduler was unable to locate a host"
                                       " for this request. Is the appropriate"
                                       " service running?"))

        LOG.debug(_("Quantum service returned host: %s") % hostname)
        return hostname
예제 #5
0
    def _get_configurations(self, instance, network, mapping):
        """Gets the device name and the profile name from Quantum"""

        instance_id = instance['id']
        user_id = instance['user_id']
        project_id = instance['project_id']
        vif_id = mapping['vif_uuid']

        instance_data_dict = \
                {'novatenant': \
                 {'instance_id': instance_id,
                  'instance_desc': \
                  {'user_id': user_id,
                   'project_id': project_id,
                   'vif_id': vif_id}}}

        client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID,
                        action_prefix=ACTION_PREFIX_CSCO)
        request_url = "/novatenants/" + project_id + ACTION
        data = client.do_request('PUT', request_url, body=instance_data_dict)

        device = data['vif_desc']['device']
        portprofile = data['vif_desc']['portprofile']
        LOG.debug(_("Quantum provided the device: %s") % device)
        LOG.debug(_("Quantum provided the portprofile: %s") % portprofile)
        mac_id = mapping['mac'].replace(':', '')

        result = {
            'id': mac_id,
            'mac_address': mapping['mac'],
            'device_name': device,
            'profile_name': portprofile,
        }

        return result
예제 #6
0
파일: cli.py 프로젝트: wendy-king/x7_venv
def schedule_host(tenant_id, instance_id, user_id=None):
    """Gets the host name from the Quantum service"""
    project_id = tenant_id

    instance_data_dict = \
            {'enginetenant': \
             {'instance_id': instance_id,
              'instance_desc': \
              {'user_id': user_id,
               'project_id': project_id}}}

    request_url = "/enginetenants/" + project_id + "/schedule_host"
    client = Client(HOST,
                    PORT,
                    USE_SSL,
                    format='json',
                    tenant=TENANT_ID,
                    action_prefix=ACTION_PREFIX_CSCO)
    data = client.do_request('PUT', request_url, body=instance_data_dict)

    hostname = data["host_list"]["host_1"]
    if not hostname:
        print("Scheduler was unable to locate a host" + \
              " for this request. Is the appropriate" + \
              " service running?")

    print("Quantum service returned host: %s" % hostname)
예제 #7
0
파일: cli.py 프로젝트: wendy-king/x7_venv
def list_extensions(*args):
    """Invoking the action to get the supported extensions"""
    request_url = "/extensions"
    client = Client(HOST,
                    PORT,
                    USE_SSL,
                    format='json',
                    action_prefix=ACTION_PREFIX_EXT,
                    tenant="dummy")
    data = client.do_request('GET', request_url)
    print("Obtained supported extensions from Quantum: %s" % data)
예제 #8
0
def create_multiport(tenant_id, networks_list, *args):
    """Creates ports on a single host"""
    ports_info = {'multiport': \
                  {'status': 'ACTIVE',
                   'net_id_list': networks_list,
                   'ports_desc': {'key': 'value'}}}
    request_url = "/multiport"
    client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id,
                action_prefix=servconts.ACTION_PREFIX_CSCO)
    data = client.do_request('POST', request_url, body=ports_info)
    return data
예제 #9
0
파일: cli.py 프로젝트: BillTheBest/quantum
def create_multiport(tenant_id, net_id_list, *args):
    """Creates ports on a single host"""
    net_list = net_id_list.split(",")
    ports_info = {'multiport': \
                  {'status': 'ACTIVE',
                   'net_id_list': net_list,
                   'ports_desc': {'key': 'value'}}}

    request_url = "/multiport"
    client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id,
                    action_prefix=ACTION_PREFIX_CSCO)
    data = client.do_request('POST', request_url, body=ports_info)

    print("Created ports: %s" % data)
 def __init__(self):
     # We have to send a dummy tenant name here since the client
     # needs some tenant name, but the tenant name will not be used
     # since the extensions URL does not require it
     client = Client(HOST, PORT, USE_SSL, format='json',
                     action_prefix=ACTION_PREFIX_EXT, tenant="dummy")
     request_url = "/extensions"
     data = client.do_request('GET', request_url)
     LOG.debug("Obtained supported extensions from Quantum: %s" % data)
     for ext in data['extensions']:
         name = ext['name']
         if name == CSCO_EXT_NAME:
             LOG.debug("Quantum plugin supports required \"%s\" extension"
                       "for the scheduler." % name)
             return
     LOG.error("Quantum plugin does not support required \"%s\" extension"
               " for the scheduler. Scheduler will quit." % CSCO_EXT_NAME)
     raise excp.ServiceUnavailable()
예제 #11
0
파일: cli.py 프로젝트: wendy-king/x7_venv
def create_multiport(tenant_id, net_id_list, *args):
    """Creates ports on a single host"""
    net_list = net_id_list.split(",")
    ports_info = {'multiport': \
                  {'status': 'ACTIVE',
                   'net_id_list': net_list,
                   'ports_desc': {'key': 'value'}}}

    request_url = "/multiport"
    client = Client(HOST,
                    PORT,
                    USE_SSL,
                    format='json',
                    tenant=tenant_id,
                    action_prefix=ACTION_PREFIX_CSCO)
    data = client.do_request('POST', request_url, body=ports_info)

    print("Created ports: %s" % data)
예제 #12
0
 def __init__(self):
     # We have to send a dummy tenant name here since the client
     # needs some tenant name, but the tenant name will not be used
     # since the extensions URL does not require it
     client = Client(HOST, PORT, USE_SSL, format='json',
                     action_prefix=ACTION_PREFIX_EXT, tenant="dummy")
     request_url = "/extensions"
     data = client.do_request('GET', request_url)
     LOG.debug("Obtained supported extensions from Quantum: %s" % data)
     for ext in data['extensions']:
         name = ext['name']
         if name == CSCO_EXT_NAME:
             LOG.debug("Quantum plugin supports required \"%s\" extension"
                       "for the VIF driver." % name)
             return
     LOG.error("Quantum plugin does not support required \"%s\" extension"
               " for the VIF driver. engine-compute will quit." \
               % CSCO_EXT_NAME)
     raise excp.ServiceUnavailable()
예제 #13
0
파일: vifdirect.py 프로젝트: emonty/quantum
    def _update_configurations(self, instance, network, mapping, action):
        """Gets the device name and the profile name from Quantum"""

        instance_id = instance['id']
        user_id = instance['user_id']
        project_id = instance['project_id']
        vif_id = mapping['vif_uuid']

        instance_data_dict = \
                {'novatenant': \
                 {'instance_id': instance_id,
                  'instance_desc': \
                  {'user_id': user_id,
                   'project_id': project_id,
                   'vif_id': vif_id}}}

        client = Client(HOST,
                        PORT,
                        USE_SSL,
                        format='json',
                        tenant=TENANT_ID,
                        action_prefix=ACTION_PREFIX_CSCO)
        request_url = "/novatenants/" + project_id + action
        data = client.do_request('PUT', request_url, body=instance_data_dict)

        if action == ASSOCIATE_ACTION:
            device = data['vif_desc']['device']
            portprofile = data['vif_desc']['portprofile']
            LOG.debug(_("Quantum provided the device: %s") % device)
            LOG.debug(_("Quantum provided the portprofile: %s") % portprofile)
            mac_id = mapping['mac'].replace(':', '')

            result = {
                'id': mac_id,
                'mac_address': mapping['mac'],
                'device_name': device,
                'profile_name': portprofile,
            }

            return result
        else:
            return data
 def __init__(self):
     # We have to send a dummy tenant name here since the client
     # needs some tenant name, but the tenant name will not be used
     # since the extensions URL does not require it
     LOG.debug("Initializing Cisco Quantum VIF driver...")
     client = Client(HOST, PORT, USE_SSL, format='json', version=VERSION,
                     uri_prefix="", tenant="dummy", logger=LOG)
     request_url = "/extensions"
     data = client.do_request('GET', request_url)
     LOG.debug("Obtained supported extensions from Quantum: %s" % data)
     for ext in data['extensions']:
         name = ext['name']
         if name == CSCO_EXT_NAME:
             LOG.debug("Quantum plugin supports required \"%s\" extension"
                       "for the VIF driver." % name)
             return
     LOG.error("Quantum plugin does not support required \"%s\" extension"
               " for the VIF driver. nova-compute will quit." \
               % CSCO_EXT_NAME)
     raise excp.ServiceUnavailable()
    def _update_configurations(self, instance, network, mapping, action):
        """Gets the device name and the profile name from Quantum"""
        LOG.debug("Cisco Quantum VIF driver performing: %s" % (action))
        instance_id = instance['uuid']
        user_id = instance['user_id']
        project_id = instance['project_id']
        vif_id = mapping['vif_uuid']

        instance_data_dict = \
                {'novatenant': \
                 {'instance_id': instance_id,
                  'instance_desc': \
                  {'user_id': user_id,
                   'project_id': project_id,
                   'vif_id': vif_id}}}

        client = Client(HOST, PORT, USE_SSL, format='json', version=VERSION,
                        uri_prefix=URI_PREFIX_CSCO, tenant=TENANT_ID,
                        logger=LOG)
        request_url = "/novatenants/" + project_id + action
        data = client.do_request('PUT', request_url, body=instance_data_dict)

        if action == ASSOCIATE_ACTION:
            device = data['vif_desc']['device']
            portprofile = data['vif_desc']['portprofile']
            LOG.debug(_("Quantum provided the device: %s") % device)
            LOG.debug(_("Quantum provided the portprofile: %s") % portprofile)
            mac_id = mapping['mac'].replace(':', '')

            result = {
                'id': mac_id,
                'mac_address': mapping['mac'],
                'device_name': device,
                'profile_name': portprofile,
            }

            return result
        else:
            return data
예제 #16
0
파일: cli.py 프로젝트: BillTheBest/quantum
def schedule_host(tenant_id, instance_id, user_id=None):
    """Gets the host name from the Quantum service"""
    project_id = tenant_id

    instance_data_dict = \
            {'novatenant': \
             {'instance_id': instance_id,
              'instance_desc': \
              {'user_id': user_id,
               'project_id': project_id}}}

    request_url = "/novatenants/" + project_id + "/schedule_host"
    client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID,
                    action_prefix=ACTION_PREFIX_CSCO)
    data = client.do_request('PUT', request_url, body=instance_data_dict)

    hostname = data["host_list"]["host_1"]
    if not hostname:
        print("Scheduler was unable to locate a host" + \
              " for this request. Is the appropriate" + \
              " service running?")

    print("Quantum service returned host: %s" % hostname)