Esempio n. 1
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(self.result, self.global_args['--output-format'],
                              self.global_args['--output-style'])

        self.load_config()

        self.account = AzureAccount(self.config)
        self.data_disk = DataDisk(self.account)

        if self.command_args['create']:
            self.__create()
        if self.command_args['delete']:
            self.__delete()
        if self.command_args['attach']:
            self.__attach()
        if self.command_args['detach']:
            self.__detach()
        if self.command_args['attached']:
            if self.command_args['show']:
                self.__show_attached()
        else:
            if self.command_args['list']:
                self.__list()
            if self.command_args['show']:
                self.__show()
Esempio n. 2
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(
            self.result,
            self.global_args['--output-format'],
            self.global_args['--output-style']
        )

        self.load_config()

        self.account = AzureAccount(self.config)

        self.image = Image(self.account)
        if self.command_args['list']:
            self.__list()
        if self.command_args['show']:
            self.__show()
        elif self.command_args['create']:
            self.__create()
        elif self.command_args['delete']:
            self.__delete()
        elif self.command_args['replicate']:
            self.__replicate()
        elif self.command_args['replication-status']:
            self.__replication_status(self.command_args['--name'])
        elif self.command_args['unreplicate']:
            self.__unreplicate()
        elif self.command_args['publish']:
            self.__publish()
        elif self.command_args['update']:
            self.__update()
Esempio n. 3
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(self.result, self.global_args['--output-format'],
                              self.global_args['--output-style'])

        self.load_config()

        self.account = AzureAccount(self.config)
        self.reserved_ip = ReservedIp(self.account)

        if self.command_args['list']:
            self.__list()
        if self.command_args['show']:
            self.__show()
        if self.command_args['create']:
            self.__create()
        if self.command_args['delete']:
            self.__delete()
        if self.command_args['associate']:
            self.__associate()
        if self.command_args['disassociate']:
            self.__disassociate()
Esempio n. 4
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(self.result, self.global_args['--output-format'],
                              self.global_args['--output-style'])

        self.load_config()

        self.account = AzureAccount(self.config)
        self.endpoint = Endpoint(self.account)
        self.endpoint.set_instance(
            self.command_args['--cloud-service-name'],
            (self.command_args['--instance-name']
             or self.command_args['--cloud-service-name']))

        if self.command_args['list']:
            self.__list()
        if self.command_args['show']:
            self.__show()
        if self.command_args['create']:
            self.__create()
        if self.command_args['update']:
            self.__update()
        if self.command_args['delete']:
            self.__delete()
Esempio n. 5
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(
            self.result,
            self.global_args['--output-format'],
            self.global_args['--output-style']
        )

        if self.command_args['list']:
            self.__list()
        elif self.command_args['default'] and not self.command_args['region']:
            self.__default()
        else:
            self.__load_account_setup(
                self.command_args['--name']
            )
            if self.command_args['remove']:
                self.__remove()
            elif self.command_args['configure']:
                self.__configure_account()
            elif self.command_args['region'] and self.command_args['add']:
                self.__region_add()
            elif self.command_args['region'] and self.command_args['default']:
                self.__set_region_default()
Esempio n. 6
0
 def setup(self):
     collector = DataCollector()
     collector.add('some-name', 'some-data')
     self.expected_out = json.dumps(
         collector.get(), sort_keys=True, indent=2, separators=(',', ': ')
     )
     self.out = DataOutput(collector)
Esempio n. 7
0
    def __sas(self, container_name, start, expiry, permissions):
        result = DataCollector()
        out = DataOutput(result, self.global_args['--output-format'],
                         self.global_args['--output-style'])

        result.add(
            self.command_args['--blob-name'] + ':sas_url',
            self.storage.disk_image_sas(container_name,
                                        self.command_args['--blob-name'],
                                        start, expiry, permissions))
        out.display()
Esempio n. 8
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(
            self.result,
            self.global_args['--output-format'],
            self.global_args['--output-style']
        )

        self.load_config()

        self.account = AzureAccount(self.config)

        # default to 1 minute ago (skew around 'now')
        if self.command_args['--start-datetime'] == 'now':
            start = datetime.datetime.utcnow() - datetime.timedelta(minutes=1)
        else:
            start = self.validate_date('--start-datetime')

        # default to 30 days from now
        if self.command_args['--expiry-datetime'] == '30 days from start':
            expiry = start + datetime.timedelta(days=30)
        else:
            expiry = self.validate_date('--expiry-datetime')

        self.validate_sas_permissions('--permissions')

        self.container = Container(self.account)

        if self.command_args['list']:
            self.__container_list()
        elif self.command_args['show']:
            self.__container_content()
        elif self.command_args['create']:
            self.__container_create()
        elif self.command_args['delete']:
            self.__container_delete()
        elif self.command_args['sas']:
            self.__container_sas(
                start, expiry, self.command_args['--permissions']
            )
Esempio n. 9
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(self.result, self.global_args['--output-format'],
                              self.global_args['--output-style'])

        self.load_config()

        self.account = AzureAccount(self.config)

        request_id = format(self.command_args['--id'])

        if self.command_args['status']:
            self.result.add('request:' + request_id,
                            self.request_status(request_id))
            self.out.display()
        elif self.command_args['wait']:
            self.request_wait(request_id)
Esempio n. 10
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(self.result, self.global_args['--output-format'],
                              self.global_args['--output-style'])

        self.load_config()

        self.account = AzureAccount(self.config)

        if self.command_args['types']:
            self.__list_instance_types()
        elif self.command_args['regions']:
            self.__list_locations()
        elif self.command_args['show']:
            self.cloud_service = CloudService(self.account)
            self.__show_cloud_service_properties()
        else:
            self.vm = VirtualMachine(self.account)
            self.cloud_service = CloudService(self.account)
            if self.command_args['create']:
                self.__create_cloud_service()
                self.__create_instance()
            elif self.command_args['delete']:
                if self.command_args['--instance-name']:
                    self.__delete_instance()
                else:
                    self.__delete_cloud_service()
            elif self.command_args['reboot']:
                self.__reboot_instance()
            elif self.command_args['shutdown']:
                self.__shutdown_instance()
            elif self.command_args['start']:
                self.__start_instance()
            elif self.command_args['status']:
                self.__operate_on_instance_state()
Esempio n. 11
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(
            self.result,
            self.global_args['--output-format'],
            self.global_args['--output-style']
        )

        self.load_config()

        self.account = AzureAccount(self.config)
        self.storage_account = StorageAccount(self.account)

        if self.command_args['--name']:
            self.validate_account_name()
        if self.command_args['--description']:
            self.validate_description()
        if self.command_args['--label']:
            self.validate_label()

        if self.command_args['create']:
            self.__create()
        elif self.command_args['update']:
            self.__update()
        elif self.command_args['show']:
            self.__show()
        elif self.command_args['list']:
            self.__list()
        elif self.command_args['delete']:
            self.__delete()
        elif self.command_args['regions']:
            self.__list_locations()
        self.out.display()
Esempio n. 12
0
    def process(self):
        self.manual = Help()
        if self.__help():
            return

        self.result = DataCollector()
        self.out = DataOutput(
            self.result,
            self.global_args['--output-format'],
            self.global_args['--output-style']
        )

        self.load_config()

        self.account = AzureAccount(self.config)

        self.fileshare = FileShare(self.account)

        if self.command_args['list']:
            self.__share_list()
        elif self.command_args['create']:
            self.__share_create()
        elif self.command_args['delete']:
            self.__share_delete()
Esempio n. 13
0
 def setup(self):
     self.collector = DataCollector()