Example #1
0
 def __init__(self, controller_ip, user, password, tenant):
     self.controller_ip = controller_ip
     auth_url = 'http://{0}:5000/v2.0/'.format(self.controller_ip)
     LOGGER.debug('Auth URL is {0}'.format(auth_url))
     self.nova = novaclient(username=user,
                            api_key=password,
                            project_id=tenant,
                            auth_url=auth_url)
     self.keystone = keystoneclient(username=user,
                                    password=password,
                                    tenant_name=tenant,
                                    auth_url=auth_url)
     self.cinder = cinderclient.Client(1, user, password,
                                       tenant, auth_url)
     self.neutron = neutronclient.Client(
         username=user,
         password=password,
         tenant_name=tenant,
         auth_url=auth_url)
     token = self.keystone.auth_token
     LOGGER.debug('Token is {0}'.format(token))
     glance_endpoint = self.keystone.service_catalog.url_for(
         service_type='image', endpoint_type='publicURL')
     LOGGER.debug('Glance endpoind is {0}'.format(glance_endpoint))
     self.glance = glanceclient(endpoint=glance_endpoint, token=token)
Example #2
0
 def _connect(self, credentials):
     return novaclient(
                 credentials['username'],
                 credentials['password'],
                 credentials['tenant'],
                 credentials['auth_url']
                 )
    def goodbye_security(self):
        auth_url = self._get_auth_url()
        nova = novaclient(username=settings.SERVTEST_USERNAME,
                          api_key=settings.SERVTEST_PASSWORD,
                          project_id=settings.SERVTEST_TENANT,
                          auth_url=auth_url)
        LOGGER.debug('Permit all TCP and ICMP in security group default')
        secgroup = nova.security_groups.find(name='default')

        for rule in secgroup.rules:
            nova.security_group_rules.delete(rule['id'])

        nova.security_group_rules.create(secgroup.id,
                                         ip_protocol='tcp',
                                         from_port=1,
                                         to_port=65535)
        nova.security_group_rules.create(secgroup.id,
                                         ip_protocol='udp',
                                         from_port=1,
                                         to_port=65535)
        nova.security_group_rules.create(secgroup.id,
                                         ip_protocol='icmp',
                                         from_port=-1,
                                         to_port=-1)
        key_name = getpass.getuser()
        if not nova.keypairs.findall(name=key_name):
            LOGGER.debug("Adding keys")
            with open(os.path.expanduser('~/.ssh/id_rsa.pub')) as fpubkey:
                nova.keypairs.create(name=key_name, public_key=fpubkey.read())
        try:
            flavor = nova.flavors.find(name='savanna')
        except:
            LOGGER.debug("Adding savanna flavor")
            nova.flavors.create('savanna', 2048, 1, 40)
Example #4
0
 def __init__(self, controller_ip, user, password, tenant):
     self.controller_ip = controller_ip
     auth_url = 'http://{0}:5000/v2.0/'.format(self.controller_ip)
     LOGGER.debug('Auth URL is {0}'.format(auth_url))
     self.nova = novaclient(username=user,
                            api_key=password,
                            project_id=tenant,
                            auth_url=auth_url)
     self.keystone = keystoneclient(username=user,
                                    password=password,
                                    tenant_name=tenant,
                                    auth_url=auth_url)
     self.cinder = cinderclient.Client(1, user, password,
                                       tenant, auth_url)
     token = self.keystone.auth_token
     LOGGER.debug('Token is {0}'.format(token))
     glance_endpoint = self.keystone.service_catalog.url_for(
         service_type='image', endpoint_type='publicURL')
     LOGGER.debug('Glance endpoind is {0}'.format(glance_endpoint))
     self.glance = glanceclient(endpoint=glance_endpoint, token=token)
Example #5
0
 def _connect(self, credentials):
     return novaclient(credentials['username'], credentials['password'],
                       credentials['tenant'], credentials['auth_url'])