def create(self, **kwargs):
     new = {}
     for (key, value) in kwargs.items():
         if key in CREATION_ATTRIBUTES:
             new[key] = value
         else:
             raise exc.InvalidAttribute()
     return self._create(self._path(), new)
Exemple #2
0
 def service_create(self, **kwargs):
     new = {}
     for (key, value) in kwargs.items():
         if key in ['name', 'enabled', 'region_name', 'capabilities']:
             new[key] = value
         else:
             raise exc.InvalidAttribute()
     return self._create(self._path(), new)
Exemple #3
0
 def upload(self, file, **kwargs):
     data = {}
     for (key, value) in kwargs.items():
         if key in CREATION_ATTRIBUTES:
             data[key] = value
         else:
             raise exc.InvalidAttribute('%s' % key)
     return self._upload_multipart(self._path(), dict(file=file), data=data)
Exemple #4
0
 def create(self, **kwargs):
     path = '/v1/iinterfaces'
     new = {}
     for (key, value) in kwargs.items():
         if key in CREATION_ATTRIBUTES:
             new[key] = value
         else:
             raise exc.InvalidAttribute('%s' % key)
     return self._create(path, new)
Exemple #5
0
 def create(self, **kwargs):
     # path = '/v1/controller_fs'
     new = {}
     for (key, value) in kwargs.items():
         if key in CREATION_ATTRIBUTES:
             new[key] = value
         else:
             raise exc.InvalidAttribute('%s' % key)
     return self._create(self._path(), new)
Exemple #6
0
 def create(self, **kwargs):
     path = '/v1/ethernet_ports/'
     new = {}
     for (key, value) in kwargs.items():
         if key in CREATION_ATTRIBUTES:
             new[key] = value
         else:
             raise exc.InvalidAttribute(key)
     return self._create(path, new)
Exemple #7
0
 def create(self, **kwargs):
     new = {}
     for (key, value) in kwargs.items():
         if key in CREATION_ATTRIBUTES:
             new[key] = value
             if key == 'services':
                 new[key] = [value]
         else:
             raise exc.InvalidAttribute('%s' % key)
     return self._create(self._path(), new)
Exemple #8
0
 def import_load(self, **kwargs):
     path = '/v1/loads/import_load'
     new = {}
     for (key, value) in kwargs.items():
         if key in IMPORT_ATTRIBUTES:
             new[key] = value
         else:
             raise exc.InvalidAttribute(key)
     res, body = self.api.json_request('POST', path, body=new)
     return body
Exemple #9
0
    def create(self, **kwargs):
        new = {}
        for (key, value) in kwargs.items():
            if key in CREATION_ATTRIBUTES:
                new[key] = value
            else:
                raise exc.InvalidAttribute('%s' % key)

        self.upload_file(new)

        ceph_conf_file = new.get('ceph_conf', None)
        new.update({'ceph_conf': os.path.basename(ceph_conf_file)})

        return self._create(self._path(), new)
Exemple #10
0
    def import_load(self, **kwargs):
        path = '/v1/loads/import_load'

        active = None
        load_info = {}
        for (key, value) in kwargs.items():
            if key in IMPORT_ATTRIBUTES:
                if key == 'active':
                    active = value
                else:
                    load_info[key] = value
            else:
                raise exc.InvalidAttribute(key)

        json_data = self._upload_multipart(
            path, body=load_info, data={'active': active}, check_exceptions=True)
        return self.resource_class(self, json_data)
Exemple #11
0
    def _create_load(self, load, path):
        if set(list(load.keys())) != set(CREATION_ATTRIBUTES):
            raise exc.InvalidAttribute()

        return self._create(path, load)