Ejemplo n.º 1
0
 def __init__(self, vnc_lib_h, connections, auth=None, project_name=None,
              username=None, password=None, role='admin', scale= False):
     self.inputs = connections.inputs
     if not project_name:
         project_name = self.inputs.stack_tenant
     self.vnc_lib_h = vnc_lib_h
     self.connections = connections
     self.auth = auth
     self.project_name = project_name
     self.project_obj = None
     self.domain_name = 'default-domain'
     self.already_present = False
     self.logger = connections.inputs.logger
     self.project_fq_name = [self.domain_name, self.project_name]
     self.username = username
     self.password = password
     self.role = role
     self.user_dict = {}
     self._create_user_set = {}
     self.project_connections = None
     self.api_server_inspects = self.connections.api_server_inspects
     self.verify_is_run = False
     self.scale = scale
     if not self.auth:
         if self.inputs.orchestrator == 'openstack':
             self.auth = OpenstackAuth(self.inputs.stack_user,
                           self.inputs.stack_password,
                           self.inputs.project_name, self.inputs, self.logger)
         else: # vcenter
             self.auth = VcenterAuth(self.inputs.stack_user,
                           self.inputs.stack_password,
                           self.inputs.project_name, self.inputs)
Ejemplo n.º 2
0
    def get_auth_h(self,
                   refresh=False,
                   project_name=None,
                   username=None,
                   password=None,
                   domain_name=None):
        project_name = project_name or self.project_name
        username = username or self.username
        password = password or self.password
        attr = '_auth_' + project_name + '_' + username
        if not getattr(env, attr, None) or refresh:
            if self.inputs.orchestrator == 'openstack':
                env[attr] = OpenstackAuth(username,
                                          password,
                                          project_name,
                                          self.inputs,
                                          self.logger,
                                          domain_name=domain_name
                                          or self.orch_domain_name,
                                          scope=self.scope)
            elif self.inputs.orchestrator == 'vcenter':
                env[attr] = VcenterAuth(username, password, project_name,
                                        self.inputs)
#            elif self.inputs.orchestrator == 'kubernetes':
#                env[attr] = self.get_k8s_api_client_handle()
        return env.get(attr)
Ejemplo n.º 3
0
 def setUp(self):
     super(VncLibFixture, self).setUp()
     if not self.connections:
         self.logger = self.logger or contrail_logging.getLogger(__name__)
         self.vnc_api_h = VncApi(username=self.username,
                                 password=self.password,
                                 tenant_name=self.project_name,
                                 domain_name=self.orch_domain,
                                 api_server_host=self.cfgm_ip,
                                 api_server_port=self.api_server_port,
                                 auth_host=self.auth_server_ip,
                                 auth_port=self.auth_port,
                                 api_server_use_ssl=self.use_ssl,
                                 auth_url=self.authn_url)
         if self.orchestrator == 'openstack':
             self.auth_client = OpenstackAuth(self.username,
                                              self.password,
                                              self.project_name,
                                              domain_name=self.orch_domain,
                                              auth_url=self.auth_url,
                                              certfile=self.certfile,
                                              keyfile=self.keyfile,
                                              cacert=self.cacert,
                                              insecure=self.insecure,
                                              logger=self.logger,
                                              scope='project')
         elif self.orchestrator == 'vcenter':
             self.auth_client = VcenterAuth(self.username, self.password,
                                            self.project_name, self.inputs)
     if self.orch:
         self.vnc_h = self.orch.vnc_h
     else:
         self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
Ejemplo n.º 4
0
 def setUp(self):
     super(VncLibFixture, self).setUp()
     if self.connections:
         self.logger = self.connections.logger
         self.project_name = self.connections.project_name
         self.inputs = self.connections.inputs
         self.neutron_handle = self.connections.quantum_h
         self.vnc_api_h = self.connections.vnc_lib
         self.username = self.connections.username
         self.password = self.connections.password
         self.cfgm_ip = self.inputs.cfgm_ip
         self.auth_server_ip = self.inputs.auth_ip
         self.project_id = self.connections.project_id
         self.auth_url = 'http://' + self.inputs.auth_ip + ':5000/v2.0'
     else:
         self.vnc_api_h = VncApi(username=self.username,
                                 password=self.password,
                                 tenant_name=self.project_name,
                                 api_server_host=self.cfgm_ip,
                                 api_server_port=self.api_server_port,
                                 auth_host=self.auth_server_ip)
         if self.orchestrator == 'openstack':
             self.auth_client = OpenstackAuth(self.username,
                                              self.password,
                                              self.project_name,
                                              auth_url=self.auth_url,
                                              logger=self.logger)
             self.project_id = self.auth_client.get_project_id()
         elif self.orchestrator == 'vcenter':
             self.auth_client = VcenterAuth(self.username, self.password,
                                            self.project_name, self.inputs)
             self.project_id = self.auth_client.get_project_id()
Ejemplo n.º 5
0
 def get_auth_h(self):
     if not getattr(self, 'auth', None):
         if self.inputs.orchestrator == 'openstack':
             self.auth = OpenstackAuth(self.username, self.password,
                                       self.project_name, self.inputs,
                                       self.logger)
         else:  # vcenter
             self.auth = VcenterAuth(self.username, self.password,
                                     self.project_name, self.inputs)
     return self.auth
Ejemplo n.º 6
0
 def setUp(self):
     super(VncLibFixture, self).setUp()
     if self.connections:
         self.logger = self.connections.logger
         self.project_name = self.connections.project_name
         self.inputs = self.connections.inputs
         self.neutron_handle = self.connections.quantum_h
         self.vnc_api_h = self.connections.vnc_lib
         self.username = self.connections.username
         self.password = self.connections.password
         self.cfgm_ip = self.inputs.cfgm_ip
         self.auth_server_ip = self.inputs.auth_ip
         self.auth_client = self.connections.auth
         self.project_id = self.connections.project_id
     else:
         self.logger = self.logger or contrail_logging.getLogger(__name__)
         self.vnc_api_h = VncApi(
                           username=self.username,
                           password=self.password,
                           tenant_name=self.project_name,
                           domain_name=self.domain,
                           api_server_host=self.cfgm_ip,
                           api_server_port=self.api_server_port,
                           auth_host=self.auth_server_ip,
                           api_server_use_ssl=self.use_ssl,
                           auth_url=self.authn_url)
         if self.orchestrator == 'openstack':
             self.auth_client = OpenstackAuth(
                                 self.username,
                                 self.password,
                                 self.project_name,
                                 domain_name=self.domain,
                                 auth_url=self.auth_url,
                                 certfile=self.certfile,
                                 keyfile=self.keyfile,
                                 cacert=self.cacert,
                                 insecure=self.insecure,
                                 logger=self.logger)
         elif self.orchestrator == 'vcenter':
             self.auth_client = VcenterAuth(self.username,
                                             self.password,
                                             self.project_name,
                                             self.inputs
                                             )
         if not self.project_id:
             self.project_id = self.vnc_api_h.project_read(
                 fq_name=[self.domain, self.project_name]).uuid
     if self.orch:
         self.vnc_h = self.orch.vnc_h
     else:
         self.vnc_h = ContrailVncApi(self.vnc_api_h, self.logger)
Ejemplo n.º 7
0
 def __init__(self,
              connections,
              auth=None,
              project_name=None,
              username=None,
              password=None,
              role='admin',
              domain_name=None,
              uuid=None):
     self.inputs = connections.inputs
     self.vnc_lib_h = connections.get_vnc_lib_h()
     self.vnc_lib_fixture = connections.vnc_lib_fixture
     self.logger = connections.logger
     self.connections = connections
     self.auth = auth
     self.project_name = project_name or self.inputs.stack_tenant
     self.orch_domain_name = domain_name or self.inputs.stack_domain
     if self.orch_domain_name == 'Default':
         self.domain_name = 'default-domain'
     else:
         self.domain_name = self.orch_domain_name
     self.domain_id = self.connections.domain_id or 'default'
     self.uuid = uuid
     self.project_obj = None
     self.already_present = False
     self.project_fq_name = [self.domain_name, self.project_name]
     self.project_username = self.username = username or self.connections.username
     self.project_user_password = self.password = password or self.connections.password
     self.role = role
     self.user_dict = {}
     self._create_user_set = {}
     self.project_connections = dict()
     self.project_inputs = dict()
     self.api_server_inspects = self.connections.api_server_inspects
     self.verify_is_run = False
     if not self.auth:
         if self.inputs.orchestrator == 'openstack':
             self.auth = OpenstackAuth(self.inputs.admin_username,
                                       self.inputs.admin_password,
                                       self.inputs.admin_tenant,
                                       self.inputs,
                                       self.logger,
                                       domain_name=self.inputs.admin_domain)
         elif self.inputs.orchestrator == 'vcenter':
             self.auth = VcenterAuth(self.inputs.admin_username,
                                     self.inputs.admin_password,
                                     self.inputs.admin_tenant, self.inputs)
         else:
             # Kubernetes
             # Set no auth for now
             self.auth = None
Ejemplo n.º 8
0
 def get_auth_h(self, refresh=False, project_name=None,
                username=None, password=None):
     project_name = project_name or self.project_name
     username = username or self.username
     password = password or self.password
     attr = '_auth_'+project_name+'_'+username
     if not getattr(env, attr, None) or refresh:
         if self.inputs.orchestrator == 'openstack':
             env[attr] = OpenstackAuth(username, password,
                        project_name, self.inputs, self.logger)
         else:
             env[attr] = VcenterAuth(username, password,
                                    project_name, self.inputs)
     return env[attr]
Ejemplo n.º 9
0
    def __init__(self,
                 inputs,
                 logger,
                 project_name=None,
                 username=None,
                 password=None):
        self.inputs = inputs
        project_name = project_name or self.inputs.project_name
        username = username or self.inputs.stack_user
        password = password or self.inputs.stack_password
        self.username = username
        self.password = password
        self.project_name = project_name

        self.vnc_lib_fixture = VncLibFixture(
            username=username,
            password=password,
            domain=self.inputs.domain_name,
            project=project_name,
            inputs=self.inputs,
            cfgm_ip=self.inputs.cfgm_ip,
            api_port=self.inputs.api_server_port)
        self.vnc_lib_fixture.setUp()
        self.vnc_lib = self.vnc_lib_fixture.get_handle()

        self.nova_h = None
        self.quantum_h = None
        if self.inputs.orchestrator == 'openstack':
            self.auth = OpenstackAuth(username, password, project_name,
                                      self.inputs, logger)
            self.project_id = self.auth.get_project_id(self.inputs.domain_name,
                                                       project_name)

            if self.inputs.verify_thru_gui():
                self.ui_login = UILogin(self, self.inputs, project_name,
                                        username, password)
                self.browser = self.ui_login.browser
                self.browser_openstack = self.ui_login.browser_openstack

            self.orch = OpenstackOrchestrator(username=username,
                                              password=password,
                                              project_id=self.project_id,
                                              project_name=project_name,
                                              inputs=inputs,
                                              vnclib=self.vnc_lib,
                                              logger=logger)
            self.nova_h = self.orch.nova_h
            self.quantum_h = self.orch.quantum_h
        else:  # vcenter
            self.auth = VcenterAuth(username, password, project_name,
                                    self.inputs)
            self.orch = VcenterOrchestrator(user=username,
                                            pwd=password,
                                            host=self.inputs.auth_ip,
                                            port=self.inputs.auth_port,
                                            dc_name=self.inputs.vcenter_dc,
                                            vnc=self.vnc_lib,
                                            inputs=self.inputs,
                                            logger=logger)

        self.api_server_inspects = {}
        self.dnsagent_inspect = {}
        self.cn_inspect = {}
        self.agent_inspect = {}
        self.ops_inspects = {}
        self.ds_inspect = {}
        self.update_inspect_handles()