Ejemplo n.º 1
0
    def run(self, cfg, migration):
        cloud = cfg.clouds[getattr(migration, self.location)]

        network_client = clients.network_client(cloud)
        compute_client = clients.compute_client(cloud)
        storage_client = clients.volume_client(cloud)
        try:
            if self.net_quota is None:
                clients.retry(network_client.delete_quota,
                              self.admin_tenant_id)
            else:
                clients.retry(
                    network_client.update_quota, self.admin_tenant_id, {
                        'quota': {
                            'network': self.net_quota['network'],
                            'subnet': self.net_quota['subnet'],
                            'port': self.net_quota['port'],
                        }
                    })
        except neutron_exceptions.NotFound:
            pass
        if self.compute_quota:
            clients.retry(compute_client.quotas.update, self.admin_tenant_id,
                          **self.compute_quota)
        if self.storage_quota:
            clients.retry(storage_client.quotas.update, self.obj_tenant_id,
                          **self.storage_quota)
Ejemplo n.º 2
0
 def discover_one(self, uuid):
     network_client = clients.network_client(self.cloud)
     try:
         raw_object = self.get(network_client, uuid)
         with model.Session() as session:
             obj = self.load_from_cloud(raw_object)
             session.store(obj)
             return obj
     except neutron_exceptions.NotFound:
         raise discover.NotFound()
Ejemplo n.º 3
0
 def discover_all(self):
     network_client = clients.network_client(self.cloud)
     for raw_object in self.list(network_client):
         try:
             with model.Session() as session:
                 session.store(self.load_from_cloud(raw_object))
         except model.ValidationError as e:
             obj_name = self.discovered_class.__name__
             id_attr = self.raw_identifier
             LOG.warning('Invalid %s %s in cloud %s: %s', obj_name,
                         raw_object[id_attr], self.cloud.name, e)
Ejemplo n.º 4
0
 def _set_network_quotas(self, tenant_id):
     network_client = clients.network_client(self.cloud)
     for quota in network_client.list_quotas(tenant_id=tenant_id)['quotas']:
         if quota['tenant_id'] == tenant_id:
             break
     else:
         quota = None
     network_client.update_quota(
         tenant_id, {'quota': {
             'network': -1,
             'subnet': -1,
             'port': -1,
         }})
     return quota
Ejemplo n.º 5
0
 def run(self, cfg, migration):
     cloud = cfg.clouds[getattr(migration, self.location)]
     network_client = clients.network_client(cloud)
     try:
         with model.Session() as session:
             net_obj_id = model.ObjectId(self.network_id, cloud.name)
             subnet_obj_id = model.ObjectId(self.subnet_id, cloud.name)
             session.delete(network.Network, object_id=net_obj_id)
             session.delete(network.Subnet, object_id=subnet_obj_id)
         clients.retry(network_client.delete_network,
                       self.network_id,
                       expected_exceptions=[neutron_exceptions.NotFound])
     except neutron_exceptions.NotFound:
         pass
Ejemplo n.º 6
0
 def _create_net(self, session):
     network_client = clients.network_client(self.cloud)
     raw_net = network_client.create_network({
         'network': {
             'name': 'tmp_vol_tx',
             'shared': False,
         },
     })
     raw_subnet = network_client.create_subnet({
         'subnet': {
             'cidr': '128.0.0.0/1',
             'ip_version': 4,
             'gateway_ip': None,
             'network_id': raw_net['network']['id']
         },
     })
     net = self.load_from_cloud(network.Network, self.cloud,
                                raw_net['network'])
     session.store(net)
     subnet = self.load_from_cloud(network.Subnet, self.cloud,
                                   raw_subnet['subnet'])
     session.store(subnet)
     return net, raw_net['network']['id'], raw_subnet['subnet']['id']