exclude az,nodetype,provider,region from namespace
This commit is contained in:
parent
8b79e771d5
commit
ef94b85a16
5 changed files with 9 additions and 4 deletions
|
|
@ -22,6 +22,7 @@ class BasicObject(object):
|
||||||
|
|
||||||
class Restful(BasicObject):
|
class Restful(BasicObject):
|
||||||
_detail_uri = None
|
_detail_uri = None
|
||||||
|
namespaced = True
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Simply reflect all the values in kwargs"""
|
"""Simply reflect all the values in kwargs"""
|
||||||
|
|
@ -58,7 +59,7 @@ class Restful(BasicObject):
|
||||||
assert subsystem, "Subsystem not specified for %s" % self.__class__.__name__
|
assert subsystem, "Subsystem not specified for %s" % self.__class__.__name__
|
||||||
for k, v in list(dict.items()):
|
for k, v in list(dict.items()):
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
if dockercloud.namespace:
|
if self.namespaced and dockercloud.namespace:
|
||||||
self._detail_uri = "/".join(["api", subsystem, self._api_version, dockercloud.namespace,
|
self._detail_uri = "/".join(["api", subsystem, self._api_version, dockercloud.namespace,
|
||||||
endpoint.strip("/"), self.pk])
|
endpoint.strip("/"), self.pk])
|
||||||
else:
|
else:
|
||||||
|
|
@ -130,7 +131,7 @@ class Immutable(Restful):
|
||||||
subsystem = getattr(cls, 'subsystem', None)
|
subsystem = getattr(cls, 'subsystem', None)
|
||||||
assert endpoint, "Endpoint not specified for %s" % cls.__name__
|
assert endpoint, "Endpoint not specified for %s" % cls.__name__
|
||||||
assert subsystem, "Subsystem not specified for %s" % cls.__name__
|
assert subsystem, "Subsystem not specified for %s" % cls.__name__
|
||||||
if dockercloud.namespace:
|
if cls.namespaced and dockercloud.namespace:
|
||||||
detail_uri = "/".join(["api", subsystem, cls._api_version, dockercloud.namespace, endpoint.strip("/"), pk])
|
detail_uri = "/".join(["api", subsystem, cls._api_version, dockercloud.namespace, endpoint.strip("/"), pk])
|
||||||
else:
|
else:
|
||||||
detail_uri = "/".join(["api", subsystem, cls._api_version, endpoint.strip("/"), pk])
|
detail_uri = "/".join(["api", subsystem, cls._api_version, endpoint.strip("/"), pk])
|
||||||
|
|
@ -148,7 +149,7 @@ class Immutable(Restful):
|
||||||
assert endpoint, "Endpoint not specified for %s" % cls.__name__
|
assert endpoint, "Endpoint not specified for %s" % cls.__name__
|
||||||
assert subsystem, "Subsystem not specified for %s" % cls.__name__
|
assert subsystem, "Subsystem not specified for %s" % cls.__name__
|
||||||
|
|
||||||
if dockercloud.namespace:
|
if cls.namespaced and dockercloud.namespace:
|
||||||
detail_uri = "/".join(["api", subsystem, cls._api_version, dockercloud.namespace, endpoint.strip("/")])
|
detail_uri = "/".join(["api", subsystem, cls._api_version, dockercloud.namespace, endpoint.strip("/")])
|
||||||
else:
|
else:
|
||||||
detail_uri = "/".join(["api", subsystem, cls._api_version, endpoint.strip("/")])
|
detail_uri = "/".join(["api", subsystem, cls._api_version, endpoint.strip("/")])
|
||||||
|
|
@ -229,7 +230,7 @@ class Mutable(Immutable):
|
||||||
# Figure out whether we should do a create or update
|
# Figure out whether we should do a create or update
|
||||||
if not self._detail_uri:
|
if not self._detail_uri:
|
||||||
action = "POST"
|
action = "POST"
|
||||||
if dockercloud.namespace:
|
if cls.namespaced and dockercloud.namespace:
|
||||||
path = "/".join(["api", subsystem, self._api_version, dockercloud.namespace, endpoint.lstrip("/")])
|
path = "/".join(["api", subsystem, self._api_version, dockercloud.namespace, endpoint.lstrip("/")])
|
||||||
else:
|
else:
|
||||||
path = "/".join(["api", subsystem, self._api_version, endpoint.lstrip("/")])
|
path = "/".join(["api", subsystem, self._api_version, endpoint.lstrip("/")])
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from .base import Immutable
|
||||||
class AZ(Immutable):
|
class AZ(Immutable):
|
||||||
subsystem = "infra"
|
subsystem = "infra"
|
||||||
endpoint = "/az"
|
endpoint = "/az"
|
||||||
|
namespaced = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _pk_key(cls):
|
def _pk_key(cls):
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from .base import Immutable
|
||||||
class Provider(Immutable):
|
class Provider(Immutable):
|
||||||
subsystem = "infra"
|
subsystem = "infra"
|
||||||
endpoint = "/provider"
|
endpoint = "/provider"
|
||||||
|
namespaced = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _pk_key(cls):
|
def _pk_key(cls):
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from .base import Immutable
|
||||||
class Region(Immutable):
|
class Region(Immutable):
|
||||||
subsystem = "infra"
|
subsystem = "infra"
|
||||||
endpoint = "/region"
|
endpoint = "/region"
|
||||||
|
namespaced = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _pk_key(cls):
|
def _pk_key(cls):
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from .base import Immutable
|
||||||
class NodeType(Immutable):
|
class NodeType(Immutable):
|
||||||
subsystem = "infra"
|
subsystem = "infra"
|
||||||
endpoint = "/nodetype"
|
endpoint = "/nodetype"
|
||||||
|
namespaced = False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _pk_key(cls):
|
def _pk_key(cls):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue