Пример #1
0
    def __init__(self,
                 highlander_url=None,
                 username=None,
                 api_key=None,
                 project_name=None,
                 auth_url=None,
                 project_id=None,
                 endpoint_type='publicURL',
                 service_type='maccleodv1',
                 auth_token=None,
                 user_id=None,
                 cacert=None):

        if highlander_url and not isinstance(highlander_url, six.string_types):
            raise RuntimeError('Highlander url should be string')

        if auth_url:
            (highlander_url, auth_token, project_id,
             user_id) = (self.authenticate(highlander_url, username, api_key,
                                           project_name, auth_url, project_id,
                                           endpoint_type, service_type,
                                           auth_token, user_id, cacert))

        if not highlander_url:
            highlander_url = "http://localhost:8989/v1"

        self.http_client = httpclient.HTTPClient(highlander_url, auth_token,
                                                 project_id, user_id)
        # Create all resource managers.
        self.maccleods = maccleods.MaccleodManager(self)
Пример #2
0
 def take_action(self, parsed_args):
     wb_mgr = maccleods.MaccleodManager(self.app.client)
     utils.do_action_on_many(
         lambda s: wb_mgr.delete(s),
         parsed_args.name,
         "Request to delete macCleod %s has been accepted.",
         "Unable to delete the specified macCleod(s)."
     )
Пример #3
0
    def take_action(self, parsed_args):
        result = maccleods.MaccleodManager(self.app.client).validate(
            parsed_args.definition.read())

        if not result.get('valid', None):
            raise exc.HighlanderClientException(
                result.get('error', 'Unknown exception.'))

        return tuple(), tuple()
Пример #4
0
    def take_action(self, parsed_args):
        maccleod = maccleods.MaccleodManager(self.app.client).create(
            parsed_args.definition.read())

        return format(maccleod)
Пример #5
0
    def take_action(self, parsed_args):
        maccleod = maccleods.MaccleodManager(self.app.client).get(
            parsed_args.name)

        return format(maccleod)
Пример #6
0
 def _get_resources(self, parsed_args):
     return maccleods.MaccleodManager(self.app.client).list()
Пример #7
0
    def take_action(self, parsed_args):
        definition = maccleods.MaccleodManager(self.app.client).get(
            parsed_args.name).definition

        self.app.stdout.write(definition or "\n")